SCAR Code:
function FastFindLadderColor: Integer;
var
i, c, n, bmp, Handle, cts:Integer;
p: TPointArray;
ca: TIntegerArray;
pa: TPointArrayArray;
W, H, S, L: Extended;
begin
if (not LoggedIn) then Exit;
bmp := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(bmp, MMX1, MMY1, MMX2, MMY2);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Handle := GetClientWindowHandle;
SetTargetBitmap(bmp);
FindColorsSpiralTolerance(MMCX - MMX1, MMCY - MMY1, p, 79973, 0, 0, MMX2 - MMX1, MMY2 - MMY1, 55);
pa := SplitTPAEx(p, 2, 2);
n := Length(pa) -1;
SortATPAFromSize(pa, 32, True);
for i := 0 to n do
if (Length(pa[i]) > 15) and (Length(pa[i]) < 42) then
begin
c := FastGetPixel(bmp, pa[i][0].x, pa[i][0].y);
//WriteLn(IntToStr(c)+' '+IntToStr(Length(pa[i])));
ColorToHSL(c, H, S, L);
if (H < 11.0) and (H > 4.5) then
if (L < 30.0) and (L > 10.0) then
begin
ca := GetColors(pa[i]);
ClearSameIntegers(ca);
if (Length(ca) = 1) then
begin
p := ReArrangeTPA(pa[i], 0, Length(pa[i]), True, True);
w := Abs(p[0].x - p[Length(p) -2].x);
p := ReArrangeTPA(pa[i], 0, Length(pa[i]), False, True);
h := Abs(p[0].y - p[Length(p) -2].y);
WriteLn('Color: '+IntToStr(c)+'w: '+FloatToStr(w)+' h: '+ FloatToStr(h));
WriteLn('ratio: '+FloatToStr(MaxE(w, h) div MinE(w, h)));
if (MaxE(w, h) div MinE(w, h) >= 1.12) and (MaxE(w, h) div MinE(w, h) <= 1.8) then
begin
Result := c;
Break;
end;
end;
end;
end;
SetLength(p, 0);
SetLength(pa, 0);
SetClientWindowHandle(Handle);
FreeBitmap(bmp);
ColorToleranceSpeed(cts);
end;
SCAR Code:
function FindLaddersIn(x1, y1, x2, y2: Integer): TPointArray;
var
i, n, bmp, Handle, cts, x, y, r:Integer;
p: TPointArray;
pa: TPointArrayArray;
W, H: Extended;
begin
if (not LoggedIn) then Exit;
if (LadderColor = 0) or (not FindColor(x, y, LadderColor, MMX1, MMY1, MMX2, MMY2)) then
LadderColor := FastFindLadderColor;
bmp := BitmapFromString(x2 - x1, y2 - y1, '');
CopyClientToBitmap(bmp, x1, y1, x2, y2);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Handle := GetClientWindowHandle;
SetTargetBitmap(bmp);
FindColorsSpiralTolerance(((x1 + x2) / 2) - x1, ((y1 + y2) / 2) - y1, p, LadderColor, 0, 0, x2 - x1, y2 - y1, 0);
pa := SplitTPAEx(p, 2, 2);
n := Length(pa) -1;
SortATPAFromSize(pa, 32, True);
for i := 0 to n do
if (Length(pa[i]) > 20) and (Length(pa[i]) < 42) then
begin
{p := ReArrangeTPA(pa[i], 0, Length(pa[i]), True, True);
w := Abs(p[0].x - p[Length(p) -2].x);
p := ReArrangeTPA(pa[i], 0, Length(pa[i]), False, True);
h := Abs(p[0].y - p[Length(p) -2].y);
if ((MaxE(w, h) div MinE(w, h)) >= 1.12) and ((MaxE(w, h) div MinE(w, h)) <= 1.8) then
begin}
SetLength(Result, r +1);
Result[r] := MiddleTPA(pa[i]);
IncEx(Result[r].x, x1);
IncEx(Result[r].y, y1);
Inc(r);
//end;
end;
SetLength(p, 0);
SetLength(pa, 0);
SetClientWindowHandle(Handle);
FreeBitmap(bmp);
ColorToleranceSpeed(cts);
end;