SRL Archive - Research & Development Lounge

AutoColor Map Color Finding


Kasi

2008-12-06 16:08:47

Well when i learnt how to use RGB, HSL and XYZ i thought it was kind confusing using it for MiniMap finding so I made this all you have to do is select the color, tol and the range of RGB, HSL And XYZ the play the script and it will print a function in the debug box if the function fails to find the color set the range higher Please Post any bugs and i put this script together in 10 mins so try not to be too harsh with you comments
Setup Lines 8-12

HelpFull Tuts About RGB, HSL And XYZ

http://www.villavu.com/forum/showthread.php?t=29072?p=384922#post384922 By Cazax

http://www.villavu.com/forum/showthread.php?t=32882 By pure1993

Creds
The basic function it prints out is based on Cazax function that he posts in his tut


Program New;
{.Include SRL/SRL.SCAR}
Var
R, G, B, I : Integer;
H, S, L, X, Y, Z : Extended;
ACFunction : TStringArray;
Const
Color = 0; // Color
Tol = 0; // Tol
RGB = 20; // Range Of RGB
HSL = 15; // Range Of HSL
XYZ = 7; // Range Of XYZ

Function UltraSum(A, B, C : Integer; Add : Boolean) : Integer;
Begin
If Add Then Result := A - B + C;
If Not Add Then Result := A - B - C;
End;

Procedure DoAutoColor;
Begin
ColorToRGB(Color, R, G, B);
ColorToHSL(Color, H, S, L);
ColorToXYZ(Color, X, Y, Z);
ACFunction := ['Function AutoColor : Integer;',
'Var',
' R, G, B, TestColor, MyColor, I, C2 : Integer;',
' H, S, L, X, Y, Z : Extended;',
' ColorsTPA : TPointArray;',
' C1 : TIntegerArray;',
'Begin',
' MyColor := '+IntToStr(Color)+';',
' FindColorsSpiralTolerance(MSCX, MSCY, ColorsTPA, MyColor, MMX1, MMY1, MMX2, MMY2, '+IntToStr(Tol)+');',
' C1 := GetColors(ColorsTPA);',
' C2 := High(C1);',
' For I := 0 To C2 Do',
' Begin',
' If RS_OnMinimap(ColorsTPA[I].X, ColorsTPA[I].Y) Then',
' Begin',
' TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);',
' If SimilarColors(TestColor, MyColor, '+IntToStr(Tol)+') Then',
' Begin',
' ColorToRGB(TestColor, R, G, B);',
' ColorToHSL(TestColor, H, S, L);',
' ColorToXYZ(TestColor, X, Y, Z);',
' If InRange(R - G, '+IntToStr(UltraSum(R, G, RGB, False))+', '+IntToStr(UltraSum(R, G, RGB, True))+') Then',
' If InRange(R - B, '+IntToStr(UltraSum(R, B, RGB, False))+', '+IntToStr(UltraSum(R, B, RGB, True))+') Then',
' If InRange(G - B, '+IntToStr(UltraSum(G, B, RGB, False))+', '+IntToStr(UltraSum(G, B, RGB, True))+') Then',
' If InRange(Round(S) - Round(H), '+IntToStr(UltraSum(Round(S), Round(H), HSL, False))+', '+IntToStr(UltraSum(Round(S), Round(H), HSL, True))+') Then',
' If InRange(Round(L) - Round(H), '+IntToStr(UltraSum(Round(L), Round(H), HSL, False))+', '+IntToStr(UltraSum(Round(L), Round(H), HSL, True))+') Then',
' If InRange(Round(S) - Round(L), '+IntToStr(UltraSum(Round(S), Round(L), HSL, False))+', '+IntToStr(UltraSum(Round(S), Round(L), HSL, True))+') Then',
' If InRange(Round(X) - Round(Y), '+IntToStr(UltraSum(Round(X), Round(Y), HSL, False))+', '+IntToStr(UltraSum(Round(X), Round(Y), XYZ, True))+') Then',
' If InRange(Round(Y) - Round(Z), '+IntToStr(UltraSum(Round(Y), Round(Z), HSL, False))+', '+IntToStr(UltraSum(Round(Y), Round(Z), XYZ, True))+') Then',
' If GetColor(ColorsTPA[i].X + 2, ColorsTPA[i].Y + 2) = TestColor Then',
' If GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1) = TestColor Then',
' Begin',
' Writeln(''MyColor = ''+IntToStr(TestColor)+'''');',
' Result := TestColor;',
' Exit;',
' End;',
' End;',
' End;',
' End;',
' Writeln(''Couldnt find My Color!'');',
' Result := MyColor;',
'End;'
];
For I := 0 To High(ACFunction) Do
Begin
WriteLn(+ACFunction[I]);
End;
End;

Begin
ClearDebug;
DoAutoColor;
End.

Post all bugs please

D1zl3

2008-12-06 17:26:00

Wow it actually works, im impressed!!

Kasi

2008-12-06 18:00:34

lol ty
Edit : Lots of people can write these they just take up time to write…

D1zl3

2008-12-06 18:04:00

For some reason my walking would hardly work before, but now the walking seems flawless.

Kasi

2008-12-06 18:06:15

ok glad i could help
Edit :Remember to post all bugs!!!

D1zl3

2008-12-06 18:08:41

From: pur3b100d
ok glad i could help
Edit :Remember to post all bugs!!!


Yup, I couldnt find any.

Kasi

2008-12-06 18:09:47

k ty for feed back

Kasi

2008-12-06 18:10:50

if any1 finds any bugs please post!!!