Log in

View Full Version : Sat and Hue



Sirenia
05-31-2012, 08:55 AM
So my problem is with what the title suggest: Hue and Sat mods. Ive tried to use the script that I found in a tut that will poop out the values for you program New;
//By Mastaraymond
//0 = Min
//1 = Max
var
I,II : integer;
RGBColor : Array[1..3] of Integer;
RGB : Array[0..1] of Array[1..3] of Integer;
XYZColor, HSLColor : Array[1..3] of Extended;
HSL,XYZ : Array[0..1] of Array[1..3] of Extended;
Colors : TIntegerArray;
Strings : Array[0..9] of String;
Procedure Init;
begin;
Colors := [];
end;
begin
Init;
For I:= 1 to 3 do
begin;
Writeln('');
RGB[0][i] := 255;
HSL[0][i] := 255; //Max is 240?
XYZ[0][i] := 255; //Max is ...?
end;
Strings[1] := 'R: ';
Strings[0] := ' ';
Strings[2] := 'G: ';
Strings[3] := 'B: ';
Strings[4] := 'H: ';
Strings[5] := 'S: ';
Strings[6] := 'L: ';
Strings[7] := 'X: ';
Strings[8] := 'Y: ';
Strings[9] := 'Z: ';
For I:= 0 to High(Colors) do
begin;
Strings[0] := Strings[0] + Padr('Color: '+inttostr(Colors[i]),16) +' | ';
ColortoRGB(Colors[i],RGBColor[1],RGBColor[2],RGBColor[3]);
ColortoHSL(Colors[i],HSLColor[1],HSLColor[2],HSLColor[3]);
ColortoXYZ(Colors[i],XYZColor[1],XYZColor[2],XYZColor[3]);
For II:= 1 to 3 do
begin;
RGB[0][II] := Min(RGBColor[II],RGB[0][II]);
RGB[1][II] := Max(RGBColor[II],RGB[1][II]);
HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
XYZ[0][II] := MinE(XYZColor[II],XYZ[0][II]);
XYZ[1][II] := MaxE(XYZColor[II],XYZ[1][II]);
end;
For II := 1 to 3 do
Strings[II] := Strings[II] +Padr(IntToStr (RGBColor[II]),16) +' | ';
For II := 4 to 6 do
Strings[II] := Strings[II] +Padr(FloatToStr(HSLColor[II-3]),16) +' | ';
For II := 7 to 9 do
Strings[II] := Strings[II] +Padr(FloatToStr(XYZColor[II-6]),16) +' | ';
end;
For I:= 0 to 9 do
Delete(Strings[i],Length(Strings[i])-2,3);
For I:= 0 to 9 do
begin;
if (I = 1) or (I = 4)or (I = 7) then Writeln('');
Writeln(Strings[i]);
end;
Writeln('');
Writeln('Highest RGB values = R: '+ Padr(FloatToStr(RGB[1][1]),3) + ' | ' +'G: '+ Padr(FloatToStr(RGB[1][2]),3) + ' | ' +'B: '+ Padr(FloatToStr(RGB[1][3]),3) );
Writeln('Lowest RGB values = R: '+ Padr(FloatToStr(RGB[0][1]),3) + ' | ' +'G: '+ Padr(FloatToStr(RGB[0][2]),3) + ' | ' +'B: '+ Padr(FloatToStr(RGB[0][3]),3) );
Writeln('Differ RGB values = R: '+ Padr(IntToStr(RGB[1][1] - RGB[0][1]),3) + ' | G: '+ Padr(inttostr(RGB[1][2] - RGB[0][2]) ,3) + ' | B: '+Padr(inttostr(RGB[1][3] - RGB[0][3]),3));
Writeln('Middle RGB values = R: '+ Padr(IntToStr((RGB[1][1] + RGB[0][1]) div 2),3) + ' | G: '+ Padr(inttostr((RGB[1][2] + RGB[0][2]) div 2),3) + ' | B: '+Padr(inttostr((RGB[1][3] + RGB[0][3]) div 2),3));
Writeln('Middle RGB color = ' + IntToStr(RGBToColor((RGB[1][1] + RGB[0][1]) div 2,(RGB[1][2] + RGB[0][2]) div 2,(RGB[1][3] + RGB[0][3]) div 2)));
Writeln('');
Writeln('Highest HSL values = H: '+ Padr(FloatToStr(HSL[1][1]),16) + ' | ' +'S: '+ Padr(FloatToStr(HSL[1][2]),16) + ' | ' +'L: '+ Padr(FloatToStr(HSL[1][3]),16) );
Writeln('Lowest HSL values = H: '+ Padr(FloatToStr(HSL[0][1]),16) + ' | ' +'S: '+ Padr(FloatToStr(HSL[0][2]),16) + ' | ' +'L: '+ Padr(FloatToStr(HSL[0][3]),16) );
Writeln('Differ HSL values = H: '+ Padr(FloatToStr(HSL[1][1] - HSL[0][1]),16) + ' | S: '+ Padr(FloatToStr(HSL[1][2] - HSL[0][2]) ,16) + ' | L: '+Padr(FloatToStr(HSL[1][3] - HSL[0][3]),16));
Writeln('Middle HSL values = H: '+ FloatToStr((HSL[1][1] + HSL[0][1]) div 2) + ' | S: '+ FloatToStr((HSL[1][2] + HSL[0][2]) div 2) + ' | L: '+FloatToStr((HSL[1][3] + HSL[0][3]) div 2));
Writeln('Middle HSL color = ' + IntToStr(HSLToColor((HSL[1][1] + HSL[0][1]) div 2,(HSL[1][2] + HSL[0][2]) div 2,(HSL[1][3] + HSL[0][3]) div 2)));
Writeln('');
Writeln('Highest XYZ values = X: '+ Padr(FloatToStr(XYZ[1][1]),16) + ' | ' +'Y: '+ Padr(FloatToStr(XYZ[1][2]),16) + ' | ' +'Z: '+ Padr(FloatToStr(XYZ[1][3]),16) );
Writeln('Lowest XYZ values = X: '+ Padr(FloatToStr(XYZ[0][1]),16) + ' | ' +'Y: '+ Padr(FloatToStr(XYZ[0][2]),16) + ' | ' +'Z: '+ Padr(FloatToStr(XYZ[0][3]),16) );
Writeln('Differ XYZ values = X: '+ Padr(FloatToStr(XYZ[1][1] - XYZ[0][1]),16) + ' | Y: '+ Padr(FloatToStr(XYZ[1][2] - XYZ[0][2]) ,16) + ' | Z: '+Padr(FloatToStr(XYZ[1][3] - XYZ[0][3]),16));
Writeln('Middle XYZ values = X: '+ FloatToStr((XYZ[1][1] + XYZ[0][1]) div 2) + ' | Y: '+ FloatToStr((XYZ[1][2] + XYZ[0][2]) div 2) + ' | Z: '+FloatToStr((XYZ[1][3] + XYZ[0][3]) div 2));
Writeln('Middle XYZ color = ' + IntToStr(XYZToColor((XYZ[1][1] + XYZ[0][1]) div 2,(XYZ[1][2] + XYZ[0][2]) div 2,(XYZ[1][3] + XYZ[0][3]) div 2)));
WritelN('');
end.
and then divide h with l to get Hue and s with l to get Sat it looks good but it doesnt work at all... After some table flipping I got a brilliant idea! Lets pick the colors with ACA and copy the values it spits out! This didnt work either however and im now kinda clueless on what 2 do :(

YoHoJo
05-31-2012, 09:37 AM
I don't know?
http://www.youtube.com/watch?v=98wVrr6GwyU
:D
I'm lost on what you are asking!

Sirenia
05-31-2012, 12:37 PM
I don't know?
http://www.youtube.com/watch?v=98wVrr6GwyU
:D
I'm lost on what you are asking!
Thanks for the link but evertyhing I know is basically from your tut's already :) I want to know what im doing wrong. The colors I used was 2437717, 2305873, 1712699 and the script spat out
Differ HSL values =
H: 0,47348484848484
S: 0,83164300202839
L: 7,25490196078431
Middle HSL color = 2042440

That would be Hue = 0.06 and Sat = 0.11 but ACA told me Hue = 0.11 and Sat 0.25 with Tol = 7

ACA and the script told me both diffrent Hue, Sat and Tol but the same "Best color". I used the same colors in both tests but since neither results work in any TPA function Ive tested (One that is from a TPA tut and one from a script) I think it must be a error on my part since the TPA work in the script with the values the scripter gave it but not with my values.
Can you see where I fudged up and help me please? :<

masterBB
05-31-2012, 01:09 PM
You could try my CTS tutorial, just follow the link in my siggy, if it doesn't work out for you I can help ;)

Home
05-31-2012, 01:14 PM
Don't compare ACA CTS2 Hue and Sat into Simbas, because they are wrong. (Simbas are correct, they shift a little bit) Correct me if I'm wrong!


~Home

Sirenia
05-31-2012, 01:21 PM
You could try my CTS tutorial, just follow the link in my siggy, if it doesn't work out for you I can help ;)

Thanks will check it out.
Very sneaky project you got idd, almost missed it ;P

x[Warrior]x3500
05-31-2012, 02:48 PM
Don't compare ACA CTS2 Hue and Sat into Simbas, because they are wrong. (Simbas are correct, they shift a little bit) Correct me if I'm wrong!


~Home

afaik, acav2 is incorrect, but this bug has been corrected in v3

Sirenia
05-31-2012, 03:23 PM
x3500;1035813']afaik, acav2 is incorrect, but this bug has been corrected in v3
So that means that v3 would return correct values? :O

x[Warrior]x3500
05-31-2012, 09:49 PM
So that means that v3 would return correct values? :O

i know for sure the hue value was an issue in v2. and i know this was adjusted in v3.
this is the code for v3's hue value:

h := MaxE(MinE(Abs(minH - h), minH + MaxHue - h), MinE(Abs(maxH - h), maxH + MaxHue - h)) / BestTolerance;

Sirenia
06-01-2012, 04:51 PM
Sorry but I gotta bump this, I cant find where ACA v3 is, ive been searching and looking but can only find the first and second version :(

x[Warrior]x3500
06-01-2012, 05:05 PM
Sorry but I gotta bump this, I cant find where ACA v3 is, ive been searching and looking but can only find the first and second version :(

http://villavu.com/forum/showthread.php?t=70704&page=2#post1001517