Public feed
#725299
function CreateRockBox(x, y, MaxW, MaxH, CTS, RockC, RockTol, ValueToCheck: Integer): Boolean;
var
x1, x2, y1, y2, z, i, ii, col1, CC, CC2: Integer;
ColorPoints, FinalPoints: Array [0..1] of TPoint;
comHSL, origHSL: HSL;
begin
z := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
for i := x to x - MaxW do
begin
x1 := x - 3;
col1 := GetColor(x1, y);
MMouse(x1, y, 0, 0);
Wait(500);
if SimilarColors(col1, RockC, RockTol) then
begin
ColorPoints[0].x := x1;
Break;
end;
end;
for i := x to x + MaxW do
begin
x2 := x + 3;
col1 := GetColor(x2, y);
MMouse(x2, y, 0, 0);
Wait(500);
if SimilarColors(col1, RockC, RockTol) then
begin
ColorPoints[1].x := x2;
Break;
end;
end;
for i := y to y - MaxH do
begin
y1 := y - 3;
col1 := GetColor(x, y1);
MMouse(x, y1, 0, 0);
Wait(500);
if SimilarColors(col1, RockC, RockTol) then
begin
ColorPoints[0].y := y1;
Break;
end;
end;
for i := y to y + MaxH do
begin
y2 := y + 3;
col1 := GetColor(x, y2);
MMouse(x, y2, 0, 0);
Wait(500);
if SimilarColors(col1, RockC, RockTol) then
begin
ColorPoints[1].y := y2;
Break;
end;
end;
MMouse(ColorPoints[0].x, ColorPoints[0].y, 0, 0);
Wait(5000);
MMouse(ColorPoints[1].x, ColorPoints[1].y, 0, 0);
Wait(5000);
CC2 := GetColor(ColorPoints[0].x, ColorPoints[0].y);
ColorToHSL(CC2, origHSL[0].Hue, origHSL[0].Saturation, origHSL[0].Luminance);
for i := ColorPoints[0].x to x - MaxW do
begin
ColorPoints[0].x := ColorPoints[0].x - 3;
CC := GetColor(ColorPoints[0].x, ColorPoints[0].y);
ColorToHSL(CC, comHSL[0].Hue, comHSL[0].Saturation, comHSL[0].Luminance);
if Abs(origHSL[0].Luminance - comHSL[0].Luminance) > ValueToCheck then
begin
WriteLog(['We have found our x1 edge']);
FinalPoints[0].x := ColorPoints[0].x;
Break;
end;
end;
CC2 := GetColor(ColorPoints[1].x, ColorPoints[1].y);
ColorToHSL(CC2, origHSL[1].Hue, origHSL[1].Saturation, origHSL[1].Luminance);
for i := ColorPoints[1].x to x + MaxW do
begin
ColorPoints[1].x := ColorPoints[1].x + 3;
CC := GetColor(ColorPoints[1].x, ColorPoints[1].y);
ColorToHSL(CC, comHSL[1].Hue, comHSL[1].Saturation, comHSL[1].Luminance);
if Abs(origHSL[1].Luminance - comHSL[1].Luminance) > ValueToCheck then
begin
WriteLog(['We have found our x2 edge']);
FinalPoints[1].x := ColorPoints[1].x;
Break;
end;
end;
CC2 := GetColor(ColorPoints[0].x, ColorPoints[0].y);
ColorToHSL(CC2, origHSL[0].Hue, origHSL[0].Saturation, origHSL[0].Luminance);
for i := ColorPoints[0].y to y - MaxH do
begin
ColorPoints[0].y := ColorPoints[0].y - 3;
CC := GetColor(ColorPoints[0].x, ColorPoints[0].y);
ColorToHSL(CC, comHSL[0].Hue, comHSL[0].Saturation, comHSL[0].Luminance);
if Abs(origHSL[0].Luminance - comHSL[0].Luminance) > ValueToCheck then
begin
WriteLog(['We have found our y1 edge']);
FinalPoints[0].y := ColorPoints[0].y;
Break;
end;
end;
CC2 := GetColor(ColorPoints[1].x, ColorPoints[1].y);
ColorToHSL(CC2, origHSL[1].Hue, origHSL[1].Saturation, origHSL[1].Luminance);
for i := ColorPoints[1].y to y + MaxH do
begin
ColorPoints[1].y := ColorPoints[1].y + 3;
CC := GetColor(ColorPoints[1].x, ColorPoints[1].y);
ColorToHSL(CC, comHSL[1].Hue, comHSL[1].Saturation, comHSL[1].Luminance);
if Abs(origHSL[1].Luminance - comHSL[1].Luminance) > ValueToCheck then
begin
WriteLog(['We have found our y2 edge']);
FinalPoints[1].y := ColorPoints[1].y;
Break;
end;
end;
MMouse(FinalPoints[0].x, FinalPoints[0].y, 0, 0);
Wait(5000);
MMouse(FinalPoints[1].x, FinalPoints[1].y, 0, 0);
Wait(5000);
end;