SRL Archive - SRL Archives

The HSL include.


R0b0t1

2007-08-20 17:28:10

Yep, when pwnaz0r made RGB.scar it inspired me to make HSL.scar.

I'm pretty sure its done now, unless someone tells me something that could be fixed.


//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » HSL Color Routines --//
//-----------------------------------------------------------------//

program HSLFunctions;
{.Include SRL/SRL.scar}

Type //Must be set. //Idea by pwnazor, I changed lots of vars.
TTol = record
Red, Green, Blue : Integer;
Hue, Sat, Lum: Extended;
end

Type //You will not need to set this.
TLoc = record
X, Y: Integer;
end;

Type //Must be set
THSL = record
Hue, Sat, Lum: Extended;
Loc: TLoc;
Tol: TTol;
end;

Type //Only used for special fucntions. See RGB.scar for RGB.
TRGB = record
Red, Green, Blue: Integer;
Loc: TLoc;
Tol: TTol;
end;

Function HSLToRGB2(TheHSL: THSL): TRGB;
begin;
HSLToRGB(TheHSL.Hue, TheHSL.Sat, TheHSL.Lum, Result.Red, Result.Green, Result.Blue);
end;

{*******************************************************************************
Function AddHSL(Color, LocX, LocY, HTol, STol, LTol: Integer): THSL;
By: R0b0t1
Credits: N/A
Description: Creates an HSL type with the parameters.
*******************************************************************************}

Function AddHSL(Color, LocX, LocY, HTol, STol, LTol: Integer): THSL;
begin;
ColorToHSL(Color, Result.Hue, Result.Sat, Result.Lum);
Result.Tol.Hue:= HTol;
Result.Tol.Sat:= STol;
Result.Tol.Lum:= LTol;
Result.Loc.X:= 0;
Result.Loc.Y:= 0;
end;

{*******************************************************************************
Function AddRGB(Color, LocX, LocY, RTol, GTol, BTol: Integer): TRGB;
By: R0b0t1
Credits: N/A
Description: Creates a RGB type with the parameters.
*******************************************************************************}

Function AddRGB(Color, LocX, LocY, RTol, GTol, BTol: Integer): TRGB;
begin;
ColorToRGB(Color, Result.Red, Result.Green, Result.Blue);
Result.Tol.Red:= RTol;
Result.Tol.Green:= GTol;
Result.Tol.Blue:= BTol;
Result.Loc.X:= LocX;
Result.Loc.Y:= LocY;
end;

{*******************************************************************************
Function ConvertRGBComp(Color: Integer; Component: String): Integer;
By: R0b0t1
Credits: N/A
Description: Converts a color to a sings RGB component (A letter).
*******************************************************************************}

Function ConvertRGBComp(Color: Integer; Component: String): Integer;
Var Rs, Gs, Bs: Integer;
begin;
ColorToRGB(Color, Rs, Gs, Bs);
Case LowerCase(Component) of
'red': Result:= Rs;
'green': Result:= Gs;
'blue': Result:= Bs;
end;
end;

{*******************************************************************************
Function ConvertHSLComp(Color: Integer; Component: String): Extended;
By: R0b0t1
Credits: N/A
Description: Converts color to a single HSL component (A letter).
*******************************************************************************}

Function ConvertHSLComp(Color: Integer; Component: String): Extended;
Var Hs, Ss, Ls: Integer;
begin;
ColorToHSL(Color, Hs, Ss, Ls);
Case LowerCase(Component) of
'hue': Result:= Hs;
'sat': Result:= Ss;
'lum': Result:= Ls;
end;
end;

{*******************************************************************************
Function CompareHSLComp(Color1, Color2: Integer): Array [0..2] of Extended;
By: R0b0t1
Credits: N/A
Description: Compares a color using the HSL components and return the tolerances
in an array (HTol, STol, LTol).
*******************************************************************************}

Function CompareHSLComp(Color1, Color2: Integer): Array [0..2] of Extended;
Hc1, Sc1, Lc1, Hc2, Sc2, Lc2, PH, PS, PL: Extended;
begin;
ColorToHSL(Color1, Hc1, Sc1, Lc1);
ColorToHSL(Color2, Hc2, Sc2, Lc2);
Result[0]:= MaxE(Hc1, Hc2) - MinE(Hc1, Hc2);
Result[1]:= MaxE(Sc1, Sc2) - MinE(Sc1, Sc2);
Result[2]:= MaxE(Lc1, Lc2) - MinE(Lc1, Lc2);
end;

{*******************************************************************************
Function CompareSinHSLComp(Color1, Color2: Integer; Component: String): Extended;
By: R0b0t1
Credits: N/A
Description: Compares two colors useing the HSL components and retuns the
tolerance of one of them
*******************************************************************************}

Function CompareSinHSLComp(Color1, Color2: Integer; Component: String): Extended;
Var Hc1, Sc1, Lc1, Hc2, Sc2, Lc2, PH, PS, PL: Extended;
begin;
ColorToHSL(Color1, Hc1, Sc1, Lc1);
ColorToHSL(Color2, Hc2, Sc2, Lc2);
Case LowerCase(Component) of
'hue':Result:= MaxE(Hc1, Hc2) - MinE(Hc1, Hc2);
'sat':Result:= MaxE(Sc1, Sc2) - MinE(Sc1, Sc2);
'lum':Result:= MaxE(Lc1, Lc2) - MinE(Lc1, Lc2);
end;
end;

{*******************************************************************************
Function BestColorHSL(Colors: TIntegerArray): THSL;
By: R0b0t1
Credits: Wizzup? For his bettercolor func which this is based off of.
Description: Picks the best color and make a THSL with the tol specified.
*******************************************************************************}

Function BestColorHSL(Colors: TIntegerArray; TolH, TolS, TolL: Integer;): THSL;
Var I: Integer;
Var H, S, L: Array of Extended;
Var bH, bS, bL: Extended;
begin;
SetLength(H, Colors);
SetLength(S, Colors);
SetLength(L, Colors);
For I:= 0 to Length(Colors) - 1 do
begin;
ColorToHSL(Colors[I]. H[I], S[I], L[I]);
bH:= bH + H[I];
bS:= bS + S[I];
bL:= bL + L[I];
end;
If (Length(Colors) < 0) Then
begin;
bH:= bH div Length(Colors);
bS:= bS div Length(Colors);
bL:= bl div Length(Colors);
end;
Result:= AddHSL(HSLToColor(bH, bS, bL), 0, 0, TolH, TolS, TolL);
end;

{*******************************************************************************
Function GetColorHSL(x, y: Integer): THSL;
By: R0b0t1
Credits: N/A
Description: Gets color at xy an returns as HSL.
*******************************************************************************}

Function GetColorHSL(x, y: Integer): THSL;
begin;
Result:= AddHSL(GetColor(x, y), x, y, 0, 0, 0);
end;

{*******************************************************************************
Function FindHSLTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL): Boolean;
By: R0b0t1
Credits: N/A
Description: Finds an HSL with the tolerances
*******************************************************************************}

Function FindHSLTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColor(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColor(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLSpiralTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLSpiralTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL:Integer): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorSpiral(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorSpiral(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLSpiralTol2(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLSpiralTol2(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorSpiral2(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorSpiral2(X, Y, HSLCol, x1, y1, x2, y2);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLCircleTol(var X, Y: Integer; TheHSL: THSL; midX, midY, Radius, TolH, TolS, TolL: Integer): Boolean;
By: R0b0t1
Credits: N/A
Description: Works like find color circles but with HSL
*******************************************************************************}

Function FindHSLCircleTol(var X, Y: Integer; TheHSL: THSL; midX, midY, Radius, TolH, TolS, TolL: Integer): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorCircle(X, Y, HSLCol, midX, midY, Radius);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorCircle(X, Y, HSLCol, midX, midY, Radius);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLTriangleTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, x3, y3, TolH, TolS, TolL: Integer): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLTriangleTol(var X, Y: Integer; x1, y1, x2, y2, x3, y3, TolH, TolS, TolL: Integer): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorTriangle(X, Y, HSLCol, x1, y1, x2, y2, x3, y1);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorTriangle(X, Y, HSLCol, x1, y1, x2, y2, x3, y1);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLAreaTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, MinArea, TolH, TolS, TolL: Integer): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLAreaTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2. MinArea, TolH, TolS, TolL: Integer): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColoredAreaTolerance(X, Y, HSLCol, x1, y1, x2, y2, MinArea, 0);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColoredAreaTolerance(X, Y, HSLCol, x1, y1, x2, y2, MinArea, 0);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLSkipBoxTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipBox: TBox): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLSkipBoxTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipBox: TBox): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorSkipBox(X, Y, HSLCol, x1, y1, x2, y2, SkipBox);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorSkipBox(X, Y, HSLCol, x1, y1, x2, y2, SkipBox);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLSkipBoxArrayTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipBoxes: TBoxArray): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLSkipBoxArrayTol(var X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipBoxes: TBoxArray): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorSkipBoxArray(X, Y, HSLCol, x1, y1, x2, y2, SkipBoxes);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorSkipBoxArray(X, Y, HSLCol, x1, y1, x2, y2, SkipBoxes);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLSkipCoordsTol(X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipPoints: TPointArray): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLSkipCoordsTol(X, Y: Integer; TheHSL: THSL; x1, y1, x2, y2, TolH, TolS, TolL: Integer; SkipPoints: TPointArray): Boolean;
Var I, B, C, HSLCol: Integer;
begin;
For I:= 0 to TolH do
begin;
For B:= 0 to TolS do
begin;
For C:= 0 to TolL do
begin;
HSLCol:= HSLToColor(TheHSL.Hue+I, TheHSL.Sat+B, TheHSL.Lum+C);
Result:= FindColorSkipCoords(X, Y, HSLCol, x1, y1, x2, y2, SkipPoints);
If (Result) Then Exit;
HSLCol:= HSLToColor(TheHSL.Hue-I, TheHSL.Sat-B, TheHSL.Lum-C);
Result:= FindColorSkipCoords(X, Y, HSLCol, x1, y1, x2, y2, SkipPoints);
If (Result) Then Exit;
end;
end;
end;
end;

{*******************************************************************************
Function FindHSLComp(var X, Y: Integer; x1, y1, x2, y2: Integer; Value: Extended; Component: String): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLComp(var X, Y: Integer; x1, y1, x2, y2: Integer; Value: Extended; Component: String): Boolean;
begin;
Case LowerCase(Component) of
'hue': Result:= FindHue(x, y, Value, x1, y1, x2, y2);
'sat': Result:= FindSaturation(x, y, Value, x1, y1, x2, y2;
'lum': Result:= FindLuminance(x, y, Value, x1, y1, x2, y2);
end
end;

{*******************************************************************************
Function FindHSLCompTol(var X, Y: Integer; x1, y1, x2, y2: Integer; Value, Tol: Extended; Component: String): Boolean;
By: R0b0t1
Credits: N/A
Description:
*******************************************************************************}

Function FindHSLCompTol(var X, Y: Integer; x1, y1, x2, y2: Integer; Value, Tol: Extended; Component: String): Boolean;
begin;
Case LowerCase(Component) of
'hue': Result:= FindHueTolerance(x, y, Value, x1, y1, x2, y2, Tol);
'sat': Result:= FindSaturationTolerance(x, y, Value, x1, y1, x2, y2, Tol);
'lum': Result:= FindLuminanceTolerance(x, y, Value, x1, y1, x2, y2, Tol);
end
end;

begin
end.

pwnaz0r

2007-08-20 18:23:43

;). Glad to inspire :p. Good Job on these btw. Hopefully we can keep these going and maybe even get some into SRL ;).

EDIT: I really think you should actually make it where it looks for the color in HSL and not Color32. That really defeats the purpose if you just convert the HSL and look for it doesn't it?

R0b0t1

2007-08-20 18:45:28

Not really, because it still has the tolerances for each "part" of the HSL.


Did you look at the loops? There is no way to search for HSL directly anyway, except for FindHue, FindLuminance, and FindSaturation. But I didn't want to use those… Unless it would work different, which it might… because it has FindHueTolerance… Hmm.



Switching… It will make it faster anyway. (So fast, it kicks your RGB ass! :p).

EDIT: Can't switch. Can't find a way to search all at onec without color32.

The Prince of Randomness?

2007-08-20 19:10:28

nice work :P

pwnaz0r

2007-08-20 19:19:51

From: r0b0t1
Not really, because it still has the tolerances for each "part" of the HSL.


Did you look at the loops? There is no way to search for HSL directly anyway, except for FindHue, FindLuminance, and FindSaturation. But I didn't want to use those… Unless it would work different, which it might… because it has FindHueTolerance… Hmm.



Switching… It will make it faster anyway. (So fast, it kicks your RGB ass! :p).

EDIT: Can't switch. Can't find a way to search all at onec without color32.


First of all, your not even searching for HSL. Your searching for Color32 so it doesn't even search for HSL. Thats why it will be faster. So basically your saying that you dont want to do it

From: r0b0t1

except for FindHue, FindLuminance, and FindSaturation. But I didn't want to use those…


even though you are trying to make "HSL.scar" Copy my pattern by making an array of all colors with one value such as H, S, or L and then search all those colors.

I dont want to start anything but you need to use HSL finding in HSL.scar ;) And what made me mad is you have to right to make this claim

Switching… It will make it faster anyway. (So fast, it kicks your RGB ass! :p).


unless your actually using HSL to find colors, not just changing to Color32.

R0b0t1

2007-08-20 19:23:25

Updated.

Now includes ALL colorfinding functions ported to use HSL. (Well, at least I think all of the color finding stuff.)



@Pnwaz0r- Wait… What did I copy of yours? Its not coming through… And BTW, you're not getting what I said about finding HSL directly. I can't really do it. I can't find a way to find all of them, and then put the positions together, as a certain luminance may be found before a saturation is found. Also, I bet that FindHue actually converts the hue to Color32 and searches for it. I can convert a Color32 value (through RGB) to a Hue value. I can show you the math.

pwnaz0r

2007-08-20 19:38:17

From: r0b0t1
Updated.

Now includes ALL colorfinding functions ported to use HSL. (Well, at least I think all of the color finding stuff.)



@Pnwaz0r- Wait… What did I copy of yours? Its not coming through… And BTW, you're not getting what I said about finding HSL directly. I can't really do it. I can't find a way to find all of them, and then put the positions together, as a certain luminance may be found before a saturation is found. Also, I bet that FindHue actually converts the hue to Color32 and searches for it. I can convert a Color32 value (through RGB) to a Hue value. I can show you the math.


No you didnt copy any of my code. I'm telling you to follow the same style. Hold on I'll show u after i ate dinner :p

R0b0t1

2007-08-20 22:38:53

Wait. I think my way works also, but a little faster (well, my way WILL work). Your way looks like it takes a long time getting the colors (In your flax spinner thread, someone complained about the speed).



EDIT: I think I get what you mean. Negative difference? I can do that.

EDIT: Fixed. If not found with positive tolerance, moves on to the negative.

pwnaz0r

2007-08-20 22:42:04

From: r0b0t1
Wait. I think my way works also, but a little faster (well, my way WILL work). Your way looks like it takes a long time getting the colors (In your flax spinner thread, someone complained about the speed).
True but that was because of the amount of colors. RGB looks not for the tolerances of R,G, and B all at the same time where as Finding Color tolerance is just one number so yes it will take longer, yet more accurately. And it really wasn't speed it was lag. I have updated since then.

R0b0t1

2007-08-20 23:02:21

Oh, all at the same time? Mine does that, but it scrolls through it.

Look more closely at the loops. It goes through varying levels, with the hue tolerance increasing less gradually, as I think that would cause the most false positives. While luminance increases more, because I would think that would cause less. (I hope. If I get more testers, I could re-arrange them)

n3ss3s

2007-08-21 09:12:51

:O Somebody might wanna giv him a cup?

R0b0t1

2007-08-21 12:42:23

:p. Thanks n3ss3s. :)



EDIT: Changed the finding stuff so it was more efficient.

LordGregGreg

2007-08-21 12:57:55

Very nicely organised and made. I cna see you put allot of work into this, and it looks good :).

I didn't know exactly how to do a few of the things you did with the types, but you organised this program so well, that i was able to easily understand and make it myself now :D

Thanks

pwnaz0r

2007-08-21 19:15:00

Let me express why this should not, in this state, be accepted. Please not R0b0t that this is in fact constructive critism.

You don't even use HSL. - This is basically what you do. Convert Color32 to HSL (AddHSL). Then in your colorfinding procedure, you convert back to Color32. So basically it goes:

Color32 -> HSL -> Color32 -> FindColor.

This IS NOT HSL colorfinding.

Make Your Hue, Saturation, and Luminance actually extended. they are extended numbers -.-

Most of the functions don't compile. - I tryed compiling them for making the colorfinding that actually uses HSL below.

Alot of the vars need to be global. - This could go under not compiling but yeah you use alot of vars where the can't be used.

You need to have the user be able to set the variable name. - In like ConvertHSLComp, you make the (unglobal) var name be hs. This means it is always Hs and it isnt even global so someone can't declare this var twice and no-one would want to have to go into the include and change it.

Take TLoc out of your parameters. - Such as AddHSL. You ask for the Loc.X, and Loc.Y but they are set to 0 anyway.



function FindHue(var x, y: Integer; Hue: Extended; x1, y1, x2, y2: Integer): Boolean;
function FindHueTolerance(var x, y: Integer; Hue: Extended; x1, y1, x2, y2: Integer; Tolerance: Extended): Boolean;
function FindSaturation(var x, y: Integer; Sat: Extended; x1, y1, x2, y2: Integer): Boolean;
function FindSaturationTolerance(var x, y: Integer; Sat: Extended; x1, y1, x2, y2: Integer; Tolerance: Extended): Boolean;
function FindLuminance(var x, y: Integer; Lum: Extended; x1, y1, x2, y2: Integer): Boolean;
function FindLuminanceTolerance(var x, y: Integer; Lum: Extended; x1, y1, x2, y2: Integer; Tolerance: Extended): Boolean;

Also - Please give credit where it is due. You made me give you credit for the FindRGB function, which all you did was said you could make one faster than me, which you were wrong as you admitted. I, however, gave you the idea of the components of the colorspaces, Most of the converting is just CreateRGB but HSL, and the comparing of single components is definatly mine because you don't even use it in yours.

I hate to be critical and come down on you so hard but all you have done for the last few days was say "attempt" to throw in my face that your HSL is somehow better than mine. You have actual Hue, Saturation, and Luminance value finders and much more time than I do. Please give credit where it is due and if your going to make HSL.scar, don't use Color32

Harry

2007-08-21 19:29:20

Owned :D ^^

R0b0t1

2007-08-21 19:43:42

You claim I am not finding HSL, when you are not finding RGB. It looks to me from your procedures, that you are just getting the color at the space and making it into RGB values and comparing them. It is the same thing as mine in a different order. The fact is, there is no way to find HSL colors without Color32 being in there somewhere. Yes, I can find a single hue, luminance, or saturation, but there is no way for me to find a "complete" HSL color with those.

Also, why should I make them global? It saves memory when they are local, and if you are so worried about a user trying to make another variable that name, why can't they change it? It saves time instead of going to the include and changing it.

About them not compiling. Read at the top. It says I think they are done, and would like people to say if something should be done. I couldn't compile them because my SCAR doesn't like types at ALL. I copy an example, it compiles, I change it, it compiles, but when I try to open that file again it won't compile. (Re-installing does not help)

Also, I don't mind criticism, as long as you spell it right. You're being a hypocrite, saying that I shouldn't use color32. You must use it, looking at your procedures. Why do you always fall back on the fact that I use Color32? You do.

Owned :D ^^


Don't speak until the person being "owned" says his side.

pwnaz0r

2007-08-21 19:49:47


You claim I am not finding HSL, when you are not finding RGB.



It looks to me from your procedures, that you are just getting the color at the space and making it into RGB values and comparing them.


Color32 –> RGB –> FindColor

-.- I only had to read the first few lines of it to find that. You basically just said I am not looking for RGB, I am just changing to RGB then look for the R, G and B values.

If you take a look at my coding.

For K := Y1 to Y2 do
begin
For I := X1 to X2 do
begin
tmpNum := ConvertRGB('red',GetColor(I,K));
If (Max(tmpNum,Red) - Min(tmpNum,Red)) <= Rtol then
begin
tmpNum := ConvertRGB('green',GetColor(I,K));
If (Max(tmpNum,Green) - Min(tmpNum,Green)) <= Gtol then
begin

I have no "FindHue",etc. So I made my own.


tmpNum := ConvertRGB('red',GetColor(I,K));

this is my "FindRed". I had to make my own original procedures to find these values. The reason I must use Color32 is because people don't know RGB as well. I could have just as easily made the parameters


CreateRGB ( R, G, B : integer).
but then everytime I made an RGB, I would have to go to paint, etc. Color32 is the basis of SCAR coloring but I do not use it to find.Here is the difference

Me : Color32 -> RGB -> FindRGB
You : Color32 -> HSL -> FindColor32.

None of these procedure are original either. They are basically all the same functions in SCAR except it takes longer because you convert to Color32 To HSL to Color32. Now if you had some specific procedures (not just creating the vars, etc) about HSL, I wouldn't be as mad because I would say to myself " Alright, this has some direction its going". You may have done the work of retyping and structuring it but face it. YOU ARE SEARCHING FOR COLOR32 IN HSL.SCAR. please face that ok? You need to have specific procedures. you need to find a way to make it work. Play around with things, experiment. And I know you are already going to come at me with a "your procedures aren't original either" so let me show you.


//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » RGB Color Routines --//
//-----------------------------------------------------------------//
// » function CreateRGB(red, green, blue : integer) : RGB;
// » function CompareColorsRGBEx(color1ex,color2ex: integer) : array of integer;
// » function CompareColorsRGB(color1, color2 : integer; reportit : boolean) : array of integer; | By Pwnaz0r
// » function CompareColorArrayRGB(colors : array of integer; reportIt : boolean) : array of integer; | By Pwnaz0r
// » function Procedure AutoColorMM(var ResultColor : integer; Color : integer; Colors : array of integer); | By Pwnaz0r
// » function MinArray(var int : integer; thearray : array of integer) : integer;
// » function FindClosestRGB(R, G, B, x1, y1, x2, y2 : Integer) : Integer; | By Pwnaz0r
// » function ConvertRGB(Name : string; Color : integer) : Integer; | By Pwnaz0r
// » function FindRGBTolerance(var x,y, RsltColor : integer; Red, Green, Blue, RTol, GTol, BTol, x1, y1, x2, y2 : integer) : boolean; | By Pwnaz0r

Some have to do with comparing RGB array and max tolerances. One Finds the closest Color in the specified area. One Gets the minimum number in an array. One does the main purpose of RGB.scar which is to find colors with tolerance.

These are all original procedures, none have ever been made. If you are going to take credit for all of this work (by work I mean not using HSL, copying most of my ideas for vars and converting and the rest is the same as SCAR's original functions, just taking longer to convert to HSL then Color32 again) then at least make some functions that have to do with HSL.

Try:

Maybe autocoloring?
Make a procedure that somehow finds the tolerances( such as HTol =5 STol = 5 and LTol = 5, then what is the max Color32 tolerance for all of those ).
Finding the middle of a group of colors.

And I must answer this question " Why do you always fall back on using Color32". First of all thats not all a fall back on. Second of all YOUR USING COLOR32 IN HSL.SCAR!Why make an include that has a procedure name "FindHSL" but looks for color32!?!?. It doesn't make sense. There is no point in making it if thats all it does.

R0b0t1

2007-08-21 19:59:48

You forgot practically all of my post that was meant to be discussed.

Also, you cant find RGB values directly. There has to be Color32 out there somewhere unless you pull a miracle out of your ass.

pwnaz0r

2007-08-21 20:22:53

Then let me discuss the rest of it.( You haven't seemed to have read my post either).


Also, why should I make them global? It saves memory when they are local, and if you are so worried about a user trying to make another variable that name, why can't they change it? It saves time instead of going to the include and changing it.


Because then scripters(like myself) find it difficult to even make a simple procedure because we can't use any of the vars it returns.



About them not compiling. Read at the top. It says I think they are done, and would like people to say if something should be done. I couldn't compile them because my SCAR doesn't like types at ALL. I copy an example, it compiles, I change it, it compiles, but when I try to open that file again it won't compile. (Re-installing does not help)


fine, that it why I told you them. Isn't that what you wanted by posting that at the top of your post? so how could you bring this against me -.-



Also, I don't mind criticism, as long as you spell it right. You're being a hypocrite, saying that I shouldn't use color32. You must use it, looking at your procedures. Why do you always fall back on the fact that I use Color32? You do.

WTF Deos Sepllnig ahve to od wthi ti? Anyways, bite me I misspelled one word. I don't use color 32. I Convert from Color32 yes. But that is because I don't have those pretty little procedures that you have(yet). Look at every procedure, I ask you. I never once search for Color32. I Convert Color32 to RGB. That is all I can do. Since I am searching for RGB, I can search for all three tolerances at once, which is the purpose and the intended purpose. How can you not see that. It searches for closer colors more thoroughly.
That is why it is used in autocoloring. Therefore, I do not use Color32, although my colors originate from it. It is never searched for or converted back to(unless that is how the procedure works, such as Autocoloring). it only converts to RGB and thats the only color space I use to search.

R0b0t1

2007-08-21 20:44:30

One last time, and freddy can smite me if I'm wrong:

YOU CAN NOT SEARCH FOR RGB/HSL VALUES ON THE SCREEN WITHOUT CONVERSIONS

Also, what is with these "magical" variables? What am I not letting scripters access? Please, tell me.

I'm not using the fact of me putting a discloser on the top.

pwnaz0r

2007-08-21 20:56:30

Ok I'm going to say this one more time -.- Let go of being mad and think about it. You are converting the color32 to HSL and back to Color32. You are searching for color32. It isn't even close to searching for HSL. If there isn't a way the make HSL procedures that actually have to do with HSL. If you can't, this include shouldn't be made.

I convert once from Color32 to RGB and use RGB to search RTol, GTol, and BTol at the same time and have many RGB related functions. I copied none. I'm not responding to this arguement anymore because of stubborness and your immaturity. Set aside being mad, like really set it aside and think about it. Else, this inlude is going no-where. As I have no Access to RS during the week nor have any desire to script since my school is much more important, I have almost no time and therefore cannot finish mine. I hope this conflit ends peacefully since it was really an arguement over nothing. All i tryed to do was give you advice, help you, and give you constructive criticism(In the very first post in which I said you don't use HSL to find.) You took that offensively and forced me to argue about nothing. The arguement is going no where and I don't wish to have bad relations with anyone, nor had the intent. I tried to show you, but you were immature and you may not admit to it but you know you were. Any others viewing this thread (such as hy) , even though they may not have expressed it in the correct way, can see my side of the arguement. Best of luck with the include, if this conflict is never resolved or if it is resolved and I continue helping with the few parts you allow.

-Pwnaz0r

R0b0t1

2007-08-22 13:39:12

Look, let ME explain the "color" finding.

Me - (Color32 =>) HSL Values => Color32 => Finding.

You (From what I understand of your procedures)- (Color32 =>) RGB Values => Comparing.

But what you do with you're color finding. Get Color32 => RGB Values => Compare with above.

Same difference. That's what I'm saying.

Also, I'm not being immature in my opinion, your just not listening to me, so I try to get your attention.

TOB

2007-08-22 15:49:24

From: r0b0t1
Look, let ME explain the "color" finding.

Me - (Color32 =>) HSL Values => Color32 => Finding.

You (From what I understand of your procedures)- (Color32 =>) RGB Values => Comparing.

But what you do with you're color finding. Get Color32 => RGB Values => Compare with above.

Same difference. That's what I'm saying.

Also, I'm not being immature in my opinion, your just not listening to me, so I try to get your attention.


What I think you mean is you convert Hue => Color32, Saturation => Color32, and Luminance => Color32. This is slower because as was mentioned it has to search for each independently and use independent tolerances. What you might want to do is search for the H=>Color32 then if found use search in a small box for S and L. To be honest, this shouldn't be included as a HSL.scar if it doesn't search for HSL without converting individually back to Color32.

LordGregGreg

2007-08-22 16:39:15

Look, here is how i see it.

Arguing about whethere it is "true" hsl is just stupid. It doesnt even matter.

Converting scar color to color32 to hsl to scar or whatever you want, it is stil the SAME COLOR. These are all just diferent representations of it! Its no big deal really.

Some people like thinking and searching hsl style, some like rgb style, this is good because it lets you thinkn hsl style.

I apreciate the work you put into this, you wored with what you had, and you made something that a scripter can use.

This is the final goal remember? I would not be able to use hsl without this, because I just wouldnt want to spend the time making all of this :P

Now please, drop the argument, this is all just representations of a color, nothing more, there is no diference between them.

Also, the speed involved in converting is minimal compared to the abilities that it provides. You want speed, make freedy have scar pump out hsl delphi style. else this is perfect.

R0b0t1

2007-08-22 18:03:08

Thank you lordgreggreg. To bad pwnaz0r isn't gunna read this thread anymore, you just kicked both our asses…


@TOB - No, I don't think thats it. If you look at my loops, it converts all of the values to an Color32 (SCAR color) value, but adds/subbtracts some depending on the loop.




EDIT: But if they don't compile like pwnaz0r said, would someone who SCAR is nice to them try to fix it? Feel free to put your name in big letters across the top…

pwnaz0r

2007-08-22 18:54:33

From: lordgreggreg

Also, the speed involved in converting is minimal compared to the abilities that it provides. You want speed, make freedy have scar pump out hsl delphi style. else this is perfect.


Exactly what I want him to do(freddy). I also need it for the RGB. Anyways the only reason I got mad is because HSL.scar wasn't using HSL. I don't care anymore and I can see some of what you said :p.

@R0b0t no I said I just wasn't going to argue anymore. :p
@TOB I think you said what I was saying perfectly.

TOB

2007-08-22 20:49:46

From: r0b0t1
@TOB - No, I don't think thats it. If you look at my loops, it converts all of the values to an Color32 (SCAR color) value, but adds/subbtracts some depending on the loop.


Yes I have to admit I did not actually read the code, just assumed from the posts, so it subtracts the ones that are irrelevant in the HSL sense and loops through a color search for the ones that are.

I still think it'd be better to bug Freddy for all this crap. :P

the scar noob

2007-08-27 15:12:03

this is crazy stuff, all i can say is that i couldn't make it and that i shut the fuck up because i do'nt get a shit of this :)