Cazax
2008-05-09 18:48:27
*Thanks to Tarajunky for explaining me autocoloring*
This one for the minimap:
MMRenewCol:
What does it do?
- Find all colors with the tolerance at Tol.
- Get the color tol range and the rgb tol range.
- Then it searchs for the lmost similar tol value compared to Tol and pick that color.
This one for the mainscreen ftw:
RenewCol:
What does it do?
- Find all colors with the tolerance at Tol.
- Get the HSL,RGB and the color tol values.
- Compare ranges searching for the most similar values.
NOTE: The tolerance is only for searching the colors, is a sort of max tol, since it start comparing a defining the correct color.
Feel free to use them :p
(Dont forget to credit me :D ).
This one for the minimap:
MMRenewCol:
Function MMRenewCol(Color : TColor; Tol : Integer): Integer;
Var
TPA : TPointArray;
Tols,Cols : TIntegerArray;
I,II,Dist,R,G,B,R1,G1,B1,MinTol : Integer;
Begin
ColorToRGB(Color, R, G, B);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, Color, MMX1, MMY1, MMX2, MMY2, Tol);
If Length(TPA) < 1 Then
Begin
Writeln('No Colors Found!');
Result := 0;
Exit;
End;
Cols := GetColors(TPA);
SetArrayLength(Tols, Length(Cols));
For I := 0 To High(Cols) Do
Begin
For II := 0 To Tol Do
Begin
If SimilarColors(Color, Cols[i], II) Then
Begin
Tols[i] := Tols[i] + II;
Break;
End;
End;
ColorToRGB(Cols[i], R1, G1, B1);
Dist := ((Max(r, r1) - Min(r, r1)) + (Max(g, g1) - Min(g, g1)) + (Max(b, b1) - Min(b, b1))) Div 3;
Tols[i] := Tols[i] + Dist;
End;
For I := 0 To High(Tols) Do
Begin
If (Tols[i] < MinTol) Then
MinTol := Tols[i];
Result := Cols[i];
End;
If Result <> 0 Then
Begin
Exit;
End;
Result := 0;
Writeln('Failed while autocoloring!');
End;What does it do?
- Find all colors with the tolerance at Tol.
- Get the color tol range and the rgb tol range.
- Then it searchs for the lmost similar tol value compared to Tol and pick that color.
This one for the mainscreen ftw:
RenewCol:
Function RenewCol(Color : TColor; Tol : Integer): TColor;
Var
TPA : TPointArray;
I,J,MinTol,Dist,MinTolTol,BestCol,BestTolCol : Integer;
Cols,Tols,MinTols : TIntegerArray;
R,R1,G1,B1,G,B : Integer;
H,S,L,H1,S1,L1: Extended;
Begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol);
If (Length(TPA) < 1) Then
Begin
Writeln('Couldn'#39't find any color');
Result := 0;
Exit;
End;
ColorToRGB(Color, R, G, B);
ColorToHSL(Color, H, S, L);
Cols := GetColors(TPA);
SetArrayLength(Tols, GetArrayLength(Cols));
SetArrayLength(MinTols, GetArrayLength(Tols));
For I := Low(Cols) To High(Tols) Do
Begin
ColorToRGB(Cols[I], R1, G1, B1);
ColorToHSL(Cols[I], H1, S1, L1);
For J := Low(Tols) To High(Tols) Do
Begin
If SimilarColors(Cols[I], Color, J) Then
Begin
Tols[I] := + J;
Break;
End;
Dist := (Round((Max(R, R1) - Min(R, R1)) + (Max(G, G1) - Min(G, G1)) + (Max(B, B1) - Min(B, B1)) + (MaxE(H, H1) - MinE(H, H1)) + (MaxE(S, S1) - MinE(S, S1)) + (MaxE(L, L1) - MinE(L, L1)))) Div (3);
Tols[I] := + Dist;
MinTols[I] := + Dist;
End;
End;
Begin
MinTol := Tols[0];
MinTolTol := MinTols[0];
Result := Cols[0];
For I := Low(Tols) To High(Tols) Do
Begin
ColorToRGB(Cols[I], R1, G1, B1);
ColorToHSL(Cols[I], H1, S1, L1);
If (Tols[I] < MinTol) Then
Begin
MinTol := Tols[I];
BestCol := Cols[I];
End;
If InRange(R - R1, (R - R1) - MinTolTol, (R - R1) + MinTolTol) And
InRange(G - G1, (G - G1) - MinTolTol, (G - G1) + MinTolTol) And
InRange(B - B1, (B - B1) - MinTolTol, (B - B1) + MinTolTol) And
InRange(Round(H - H1), (Round(H -H1)) - MinTolTol, (Round(H - H1)) + MinTolTol) And
InRange(Round(S - S1), (Round(S -S1)) - MinTolTol, (Round(S - S1)) + MinTolTol) And
InRange(Round(L - L1), (Round(L -L1)) - MinTolTol, (Round(L - L1)) + MinTolTol) Then
Begin
BestTolCol := Cols[I];
MinTolTol := MinTols[I];
End;
End;
If (BestTolCol <> 0) Or (BestCol <> 0)Then
Begin
Result := (BestTolCol + BestCol) Div (2);
Exit;
End;
Writeln('Failed while autocoloring!');
Result := 0;
End;
End;*RGB + HSL*What does it do?
- Find all colors with the tolerance at Tol.
- Get the HSL,RGB and the color tol values.
- Compare ranges searching for the most similar values.
NOTE: The tolerance is only for searching the colors, is a sort of max tol, since it start comparing a defining the correct color.
Feel free to use them :p
(Dont forget to credit me :D ).