[Runtime Error] : Exception: Canvas does not allow drawing in line 405 in script
Whole procedure
SCAR Code:
function ShieldColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MSCX, MSCY, arP, 2329584, MSX1, MSY1, MSX2, MSY2, 17);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the shield color.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 8.44) and (H <= 8.56) and (S >= 76.87) and (S <= 98.20) and (L >= 50.76) and (L <= 56.88) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 39.74) and (X <= 51.30) and (Y >= 32.50) and (Y <= 41.91) and (Z >= 5.60) and (Z <= 7.15) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the shield color.');
end;
Called using:
SCAR Code:
if FindColor(x,y,ShieldColor,MSX1, MSY1, MSX2, MSY2) then
Mouse(x, y, 1, 1,true);