PDA

View Full Version : Colortolerancespeed2modifiers



Negaal
03-04-2008, 06:42 PM
ColorToleranceSpeed 2

Ok, here we go.

ColorToleranceSpeed 2 is used to find colors between several colors.
The color itself is bit special aswell.
It's been combined using 2 or more colors picked from object.

ColorToleranceSpeed is called as CTS in further.

These are CTS2 procedures



procedure ColorToleranceSpeed(x: Integer);
Sets the speed of tolerance comparisons.
ColorToleranceSpeed(1) is a little slower then 0 but more accurate.
ColorToleranceSpeed(0) is faster but not as accurate as 1.
ColorToleranceSpeed(2) uses Hue, Saturation and Lightness to determine color similarity.

function GetColorToleranceSpeed: Integer;
Returns the current tolerancespeed.

procedure SetColorspeed2Modifiers(huemodifier, saturationmodifier: Extended);
These work when ColorToleranceSpeed(2) has been set.
Normally Tolerance parameter in this mode applies to Luminance directly.
For an example, SimilarColors(c1, c2, 10) would work if both colors differ by 10 max luminance.
After calling SetColorspeed2Modifiers(0.2, 2) it would mean that SimilarColors(c1, c2, 10) would
check for Hue in range of 2 and Saturation in range of 20. Default huemodifier and saturationmodifier is 0.2.



First one speaks for itself.

Second one is needed to set back original CTS.
Example, IsUpText doesn't work when CTS is 2.
Or you can simply set it to 1 after your colorfinding.

Example

function FindC(x, y, Color : integer) : boolean;
var
CTS, I, L : Integer;
TPA : TpointArray;
begin
CTS := GetColorToleranceSpeed;
Colortolerancespeed(2)
SetColorspeed2Modifiers(0.123, 0.321);
FindColorsTolerance(TPA, Color, 0, 0, 100, 100, 10);
SetColorspeed2Modifiers(0.2, 0.2);
Colortolerancespeed(CTS)
L := High(TPA)
For I := 0 to L do
begin
MMouse(TPA[i].x, TPA[i].y, 5, 5)
if IsUpText('blah') then
begin
x := TPA[i].x;
y := TPA[i].y;
Result := True
Exit;
end;
end;
end;


If we will remove "Colortolerancespeed(CTS)" then this function will never return true.
Also set the CTS2 modifiers back to default, both 0,2.

Third, sets the saturation and hue modifier.
Now there is a question how to set? Which ones are best?
It all depends about differance of colors.

Some sort of max, min and differ HSL(Hue, Sat, Luminance) writelner is needed now.

Let's take mastaraymonds one. Also let's hope he won't kill me:eek:.
Edit: Or use that one what Mastaraymond posted below.


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.


"Colors := [];"
See this? Here you need to enter the colors you pick from object. Seperate with comma.
e.g. "Colors := [123,1234,12345];"

Try to pick much different colors as you can if there are not same coloured object nearby.
Try to pick 5 or more if possible.

Enter them and press run.

Scroll up where are HSL ranges.
We find hue, saturation and tolerance using differ.

Tolerance = luminance differ
Huemod = hue differ / lum difffer
Satmod = sat differ / lum differ
Color - Hue * Sqrt(Luminance) / Sat... No for god sake! It's middle HSL color

See the example.



Highest HSL values = H: 55,9523820877075 | S: 29,1666656732559 | L: 35,2941185235977
Lowest HSL values = H: 55,0505042076111 | S: 19,2052990198135 | L: 9,41176488995552
Differ HSL values = H: 0,901877880096436 | S: 9,96136665344238 | L: 25,8823536336422
Middle HSL values = H: 55,5014431476593 | S: 24,1859823465347 | L: 22,3529417067766
Middle HSL color = 4668971


Hue mod - 0.9 = 0.036 - Thats not good if it's under 0.1 or so.
I suggest you to just make it to 0.1 if it's lower than that.
Sat - 9.961 = 0,4
Tolerance = 25
Color - 4668971

Here, try this one some rune item(s).

function FindIt(var x, y : integer) : Boolean;
var
TPA : TPointArray;
ATPA : T2DPointArray;
I, CTS, L : integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.1, 0.4);
FindColorsTolerance(TPA, 4668971, MSX1, MSY1, MSX2, MSY2, 25);
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := SplitTPAEx(TPA, 5, 5);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= 100 then
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
Wait(50 + random(50));
if (pos('une', rs_GetUpText) > 0) then
begin
GetMousePos(x, y);
Result := True;
Exit;
end;
end;
end;



Result:
http://i28.tinypic.com/2a9aeko.jpg
Instead of finding some few pixels it finds all of them.
Edit: Also note that I didn't do it in MS Paint, Wizzup's DebugATPA ftw!


So this is all.
Note that I didn't learned this myself.
Main helpers were Nielsie and Markus,
I'd wish to thank them now:)

Oh, also when I finished this tutorial I noticed Nielsie and Sumilion released ACA2 what turned my tutorial kinda pointless. Hope that someone still gets something out of it.

Have fun ;)

Naum
03-04-2008, 06:46 PM
Very good tut Negaal!
+Repz0rs

EvilChicken!
03-04-2008, 07:55 PM
Oh, also when I finished this tutorial I noticed Nielsie and Sumilion released ACA2 what turned my tutorial kinda pointless. Hope that someone still gets something out of it.

Thanks, really good tut. Simple yet explaining. I actually understoppd TPAs now! What you you mean with "ACA2"? Searched it and got nothing.. ? *hides in corner*

Negaal
03-04-2008, 08:00 PM
Thanks, really good tut. Simple yet explaining. I actually understoppd TPAs now! What you you mean with "ACA2"? Searched it and got nothing.. ? *hides in corner*

Look into public test corner.

mastaraymond
03-06-2008, 02:52 PM
No application can replace the work of human thinking :p.

Nice tut (I think that scar is a doing a bit weird with CTS 2 anyway). And the "differ" in my writelner is (Max - Min).. So to get the real "middle" you should divide it by two.. (Max - Min) / 2

Btw an "updated" version of my color writelner, just incase you need it :rolleyes:


program New;
//By Mastaraymond
//0 = Min
//1 = Max
//2 = Middle
Const
RangePercent = 0.1;
Type
Test = Array[0..2] of Array[1..4] of Extended;
var
I,II : integer;
RGBColor : Array[1..3] of Integer;
// RGB : Array[0..2] of Array[1..3] of Integer;
RGB : Test;
XYZColor, HSLColor,HSVColor : Array[1..3] of Extended;
HSL,XYZ,HSV,CMYK : Test;
CMYKColor : Array[1..4] of Extended;
Colors : TIntegerArray;
Strings : Array of String;
Procedure Init;
begin;
// Colors := [5198934 ,5135441,6381669,4604231,6449246 ,4671810,5526097 ,5458771 ];//,2703449,1582132,1782329,1648439,2176330,2703192,2 242380,1782329];
//Colors := [3684924 ,3621431 , 4867659 ,3090221 ,4935236 ,3157800 ,4012087 ,3944761 ];
Colors := [2840957 ,4087185 , 2309747 ,4154762 ,2377326 ,3231613 ,3164287 ];
//Colors := [2911630];
//Colors := [4086936,1128544,1066342 ,2312570 , 535132 ,2380147 ,602711 ,1456998 ,1389672 ];
//Colors := [4283764 , 3825769 ,4483447 ,3826793 , 3628128 , 3561053 , 4024685,4615546]; //Road
//Colors := [5141898 , 4618365 ,5275021 ,4684416 , 4485494 ,4485494,4882052 ]; //Wall
//{ RockColors Grey} Colors := [5854309,5198934 ,5135441,6381669 ,4604231,6449246,4671810,5526097,5458771,6908784];
// 4013622{ RockColors Grey Darker} Colors := [ 3684924 ,3621431,4867659,3090221,4935236,3157800,4012087, 3944761];
// 6310431{ RockColors Grey Darkest} Colors := [2106406,2042913,328914,1511703,3356718,1579282,243 3569 ,2366243];
//Colors := [6908784,5394774,3816256,6974322,8220769,6908529,65 84702,6776687,6189687];
//{Mime White}Colors := [8882328,9474209,13818088,11645377,11843270,1335753 7,11776964,11645377,11250363,10066345,12040393,123 69614];
//{Mime Black} Colors := [2567223,3948878,4607327,4804706,3290944,5133671,40 80984];
{Gas NEW rock} Colors := [8425623,10924982,7703440,8687247,9214623,8950938,1 0398384,9872296,10398384,7307916];
{Anvil} Colors := [6316392,5724254,3815998,5987426,4145220,5526619,62 50599,4342343,5395032];
//{Bank} Colors := [3744043,6242636,6636881];
//{Door} Colors := [5802137,3428442];
//{Bank Brown} C olors := [2772828,2116184];
//{Bank grey} Colors := [4408136, 4079170,3881791,4737358];
//{Servan} Colors := [4216689,4084846,5073031, 8168915,5336719,7313091,5205132];
{Fishing spot colors } Colors := [16315112,15717309,14658440,14398100,11640193,14796 717,11507072,14926246,15717294,14796723];
{Cage colors} Colors := [938360,804456,870764,736602,803683];
//{Trees} Colors := [399127,1780008,405550,531998];
//{Trees shadow} Colors := [198919,1027,264456,660498,329992]
{Trees Green} Colors := [1456698,1653044,1981744,1982001];
{Bank Booth EDGE} Colors := [3691619,3428189,3164502,3164502,2900815,2507859];
end;

function XYZtoColor(X,Y,Z : extended) : TColor;
var
R, G, B : integer;
begin;
XYZtoRGB(x,y,z,R,G,B);
Result := RGBtoColor(R,G,B);
end;
Function RGBToColorFloat( R , G , B : Extended) : TColor;
begin;
Result := RGBtoColor(Round(R),Round(G),Round(B));
end;
Function HSLToColorFloat(H,S,L : Extended) : TColor;
begin;
Result := HSLToColor(H,S,L);
end;
Procedure RGBToCMYK(R,G,B : integer;var C,M,Y,K : Extended);
begin;
C := R / 255;
M := G / 255;
Y := B / 255;
C := 1 - C;
M := 1 - M;
Y := 1 - Y;
K := 1;
if ( C < 1 ) then K := C;
if ( M < K ) then K := M;
if ( Y < K ) then K := Y;
if K = 1 then
begin;
C := 0
M := 0
Y := 0
end else
begin;
C:= ( C - K ) / ( 1 - K ) * 100
M:= ( M - K ) / ( 1 - K ) * 100
Y:= ( Y - K ) / ( 1 - K ) * 100
K := K * 100
end;

end;

Procedure CMYKToRGB(C,M,Y,K : Extended;var r,g,b : integer);
begin;
R := Round(( 1 - ( C * ( 1 - K ) + K ) ) * 255);
G := Round(( 1 - ( M * ( 1 - K ) + K ) ) * 255);
B := Round(( 1 - ( Y * ( 1 - K ) + K ) ) * 255);
end;

Function CMYKToColor(C,M,Y,K : Extended) : TColor;
var
R, G, B : integer;
begin;
CMYKToRGB(C/100,M/100,Y/100,K/100,R,G,B);
Result := RGBtoColor(R,G,B);
end;

Procedure HSVToRGBRay(H,S,V : Extended;var R,G,B : integer);
var
Var_h,var_i,Var_1,Var_2,Var_3,var_r,var_g,var_b: Extended;
begin;
V := V / 100;
S := S / 100;
H := H / 100;
if S = 0 then
begin;
R := Round(V * 255);
G := Round(V * 255);
B := Round(V * 255);
end else
begin;
var_h := H * 6
if ( var_h = 6 ) then var_h := 0; //H must be < 1
var_i := floor( var_h ) //Or ... var_i = floor( var_h )
var_1 := V * ( 1 - S )
var_2 := V * ( 1 - S * ( var_h - var_i ) )
var_3 := V * ( 1 - S * ( 1 - ( var_h - var_i ) ) )
if ( var_i = 0 ) then begin; var_r := V ; var_g := var_3 ; var_b:= var_1 end
else if ( var_i = 1 ) then begin; var_r := var_2 ; var_g := V ; var_b := var_1 end
else if ( var_i = 2 ) then begin; var_r := var_1 ; var_g := V ; var_b := var_3 end
else if ( var_i = 3 ) then begin; var_r := var_1 ; var_g := var_2 ; var_b := V end
else if ( var_i = 4 ) then begin; var_r := var_3 ; var_g := var_1 ; var_b := V end
else begin; var_r := V ; var_g := var_1 ; var_b := var_2 end;
R := round(var_r * 255) //RGB results = 0 รท 255
G := round(var_g * 255)
B := Round(var_b * 255)
end;
end;
Function HSVToColor(H,S,V : Extended) : TColor;
var
R, G, B : integer;
begin;
HSVToRGBRay(H,S,V,R,G,B);
Result := RGBtoColor(R,G,B);
end;

Procedure RGBToHSVRay(RR,GG,BB : integer;var H,S,V : Extended);
var
R, G, B, D, Cmax, Cmin: Extended;

begin
R := RR / 255;
G := GG / 255;
B := BB / 255;
CMin := R;
if G < Cmin then Cmin := G;
if B < Cmin then Cmin := B;
CMax := R;
if G > Cmax then Cmax := G;
if B > Cmax then Cmax := B;
D := Cmax - Cmin;
V := CMax;
if Cmax = 0 then
S := 0
else
S := D / CMax;
if Cmax = CMin then
H := 0
else
begin;
if R = Cmax then
H := (G - B) / D
else
if G = Cmax then
H := 2 + (B - R) / D
else
H := 4 + (R - G) / D;
H := H / 6;
if H < 0 then
H := H + 1;
end;
H := H * 100;
S := S * 100;
V := V * 100;
end;

Procedure WriteData(ColorProc : String; Data :Test; Name : String;PadAt : integer);
var
I,len : integer;
StrArr : Array of String;
V : TVariantArray;
S : Array of String;
begin;
Len := Length(Name) - 1;
SetLength(s,Len + 1);
For I := 1 to Len + 1 do
S[I - 1] := Name[I];
SetLength(StrArr,4);
SetLength(V,Len + 1);
StrArr[0] := 'Highest '+Name+' values = '+S[0]+': '+ Padr(FloatToStr(Data[1][1]),PadAt);
StrArr[1] := 'Lowest '+Name+' values = '+S[0]+': '+ Padr(FloatToStr(Data[0][1]),PadAt);
StrArr[2] := 'Differ '+Name+' values = '+S[0]+': '+ Padr(FloatToStr(Data[1][1] - Data[0][1]),PadAt);
StrArr[3] := 'Middle '+Name+' values = '+S[0]+': '+ Padr(FloatToStr(Data[2][1]),PadAt);
For I := 1 to Len do
begin;
StrArr[0] := StrArr[0] + ' | '+S[I]+': '+ Padr(FloatToStr(Data[1][I+ 1]),PadAt);
StrArr[1] := StrArr[1] + ' | '+S[I]+': '+ Padr(FloatToStr(Data[0][I+ 1]),PadAt);
StrArr[2] := StrArr[2] + ' | '+S[I]+': '+ Padr(FloatToStr(Data[1][I+ 1] - Data[0][I+ 1]) ,PadAt);
StrArr[3] := StrArr[3] + ' | '+S[I]+': '+ Padr(FloatToStr(Data[2][I+ 1]),PadAt);
end;
For I := 0 to 3 do
Writeln(StrArr[I]);
For I := 0 to Len do
V[I] := DATA[2][I + 1];

Writeln('Middle '+Name+' color = ' + FloatToStr( ThreadSafeCall(ColorProc,V)));
WritelN('');
end;
begin
Init;
For I:= 1 to 3 do
begin;
Writeln('');
RGB[0][I] := 255;
HSL[0][I] := 999; //Max is 240?
XYZ[0][I] := 999; //Max is ...?
HSV[0][I] := 999; //Donno x)
end;
For I:= 1 to 4 do
CMYK[0][I] := 999;
Strings := [' ','R: ','G: ','B: ','H: ','S: ','L: ','X: ','Y: ','Z: ','C: ','M: ','Y: ','K: ','H: ','S: ','V: '];
For I:= 0 to High(Colors) do
begin;
Strings[0] := Strings[0] + Padr('Color: '+FloatToStr(Colors[I]),16) +' | ';
ColortoRGB(Colors[I],RGBColor[1],RGBColor[2],RGBColor[3]);
ColortoHSL(Colors[I],HSLColor[1],HSLColor[2],HSLColor[3]);
RGBToCMYK(RGBColor[1],RGBColor[2],RGBColor[3], CMYKColor[1],CMYKColor[2],CMYKColor[3],CMYKColor[4]);
RGBtoXYZ(RGBColor[1],RGBColor[2],RGBColor[3],XYZColor[1],XYZColor[2],XYZColor[3]);
RGBToHSVRay(RGBColor[1],RGBColor[2],RGBColor[3],HSVColor[1],HSVColor[2],HSVColor[3]);
For II:= 1 to 3 do
begin;
RGB[0][II] := MinE(RGBColor[II],RGB[0][II]);
RGB[1][II] := MaxE(RGBColor[II],RGB[1][II]);
RGB[2][II] := (RGB[0][II] + RGB[1][II]) / 2.0;
HSL[0][II] := MinE(HSLColor[II],HSL[0][II]);
HSL[1][II] := MaxE(HSLColor[II],HSL[1][II]);
HSL[2][II] := (HSL[0][II] + HSL[1][II]) / 2.0;
XYZ[0][II] := MinE(XYZColor[II],XYZ[0][II]);
XYZ[1][II] := MaxE(XYZColor[II],XYZ[1][II]);
XYZ[2][II] := (XYZ[0][II] + XYZ[1][II]) / 2.0;
HSV[0][II] := MinE(HSVColor[II],HSV[0][II]);
HSV[1][II] := MaxE(HSVColor[II],HSV[1][II]);
HSV[2][II] := (HSV[0][II] + HSV[1][II]) / 2.0;
end;
For II := 1 to 4 do
begin;
CMYK[0][II] := MinE(CMYKColor[II],CMYK[0][II]);
CMYK[1][II] := MaxE(CMYKColor[II],CMYK[1][II]);
CMYK[2][II] := (CMYK[0][II] + CMYK[1][II]) / 2.0;
end;

For II := 1 to 3 do
Strings[II] := Strings[II] +Padr(FloatToStr (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) +' | ';
For II := 10 to 13 do
Strings[II] := Strings[II] +Padr(FloatToStr(CMYKColor[II-9]),16) +' | ';
For II := 14 to 16 do
Strings[II] := Strings[II] +Padr(FloatToStr(HSVColor[II-13]),16) +' | ';
end;
For I:= 0 to 16 do
Delete(Strings[I],Length(Strings[I])-2,3);
For I:= 0 to 16 do
begin;
if (I = 1) or (I = 4)or (I = 7) or(I=10) or (I = 14) then Writeln('');
Writeln(Strings[I]);
end;
WritelN('');
WriteData('CMYKToColor',CMYK,'CMYK',17);
WriteData('HSVToColor' ,HSV ,'HSV',17);
WriteData('RGBToColorFloat' ,RGB ,'RGB',3);
WriteData('HSLToColorFloat' ,HSL ,'HSL',17);
WriteData('XYZToColor' ,XYZ ,'XYZ',17);
end.

Negaal
03-06-2008, 04:19 PM
@Raymond
Thanks, looks much l33ter than first version. Though commented colors are much useful for me, first version working good too:)

bullzeye95
03-08-2008, 01:44 AM
Nice tutorial, I use these in every object finding function I make.

Like Raymond was saying (I think?), CTS2 is, I think, kind of messed up... me, Ray, and Markus did some testing one day and couldn't figure out what exactly it does... I don't know if they tested it further, but I've always just thought of it the way that you explained it and it works fine for me.

mastaraymond
03-08-2008, 01:19 PM
Nice tutorial, I use these in every object finding function I make.

Like Raymond was saying (I think?), CTS2 is, I think, kind of messed up... me, Ray, and Markus did some testing one day and couldn't figure out what exactly it does... I don't know if they tested it further, but I've always just thought of it the way that you explained it and it works fine for me.
Yes he explained it very well. Its just that it doesn't make much sense. If ColorSpeedModifiers2 just had like H,S,L mod, would make much more sense..

ShowerThoughts
03-08-2008, 01:28 PM
can some1 explain this on msn to me very noob friendly? xD

HellBoyz
03-17-2008, 04:12 AM
woot nice tut but can't digest in one shoot so bookmark for further study...

Heavenzeyez1
08-28-2008, 09:43 PM
This is awesome , finally i got it . :rolleyes:
~Eerik~