SRL Archive - SRL Archives

AutoColor(Color,tol:Integer): Integer;


NiCbaZ

2009-05-12 14:46:42

Needs testing, should work in theory.

Function

[PHP]function AutoColor(Color,tol:Integer): Integer;
var
H,S,L,X,Y,Z : Extended;
R,G,B,P,A,TestColor : Integer;
TPA : TPointArray;

begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, Color, MMX1, MMY1, MMX2, MMY2,tol);
for A := 0 to High(TPA) do
begin
if RS_OnMinimap(TPA[A].X, TPA[A].Y) then
begin
TestColor := GetColor(TPA[A].X, TPA[A].Y);
if SimilarColors(TestColor, Color, 50) then
begin
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);
ColorToRGB(TestColor, R, G, B);

if InRange(R - G, -20, 20) then
if InRange(R - B, -20, 20) then
if InRange(G - B, -20, 20) then

if InRange(Round(H - L), -15, 15) then
if InRange(Round(S - H), -15, 15) then
if InRange(Round(S - L), -15, 15) then

if InRange(Round(X) - Round(Y), -7, 7) then
if InRange(Round(Y) - Round(Z), -7, 7) then

if GetColor(TPA[A].X + 2, TPA[A].Y + 2) = TestColor then
if GetColor(TPA[A].X + 1, TPA[A].Y + 1) = TestColor then

begin
Result := TestColor;
Exit;
end;
end;
Result := 0;
Exit;
end;
end;
end;[/PHP]

Use


[PHP]
var
VarrockRoad,RockColor: Integer;

begin
VarrockRoad:= AutoColor(213423,50);
if VarrockRoad <> 0 then
Exit;
for I:= 0 to 8 do
RadialWalk(blahh,180 + I,VarrockRoad);
RockColor:= AutoColor(21312333,50);
RadialWalk(Stuff)
[/PHP]

Nava2

2009-05-12 16:32:48

No, no it shouldn't.

The range of RGB changes, its far from static. You will miss a LOT of colours.

Sorry to be blunt.

NiCbaZ

2009-05-13 01:29:53

Oh ok, sorry then i did work a few times for me in testing:/

Cazax

2009-05-13 01:33:43

Autocoloring with static tolerance it's somewhat reliable, unless the range is too big: http://www.villavu.com/forum/showthread.php?t=40572