type
TArea = record;
color : integer;
tol : integer;
h, s : extended;
count : integer;
TPA: TPointArray;
end;
TElement = record;
TP : TPoint; // (where is the element)
color : integer;
tol: integer;
h, s: extended
end;


//thank boreas
type
TCircle = record
Center: TPoint
Radius: integer;
end;
function SortCirclesByRadius(Circles:TCircleArray): TCircleArray;
begin
//bubblesort should do if there aren't many circles
end;
{*******************************************************************************
function CircleTPA(cX, cY, r: Integer): TPointArray;
By: Nava2
Description: Creates a TPA of a circle with radius 'r' and center point cX, cY.
*******************************************************************************}
function CircleTPA(cX, cY, r: Integer): TPointArray;
var
i, j, l, tX, tY: Integer;
begin
setLength(Result, 4 * r * r);
l := 2 * r - 1;
tX := cX - r;
tY := cY - r;
for i := 0 to l do
for j := 0 to l do
Result[j + l * i] := Point(tX + i, tY + j);
Result := RemoveDistTPointArray(cX, cY, r, Result, True);
end;
function CircleMatch(Circles: TCircleArray): TPointArray;
var
TheTPA: TPointArray;
i, i2: integer;
begin
TheTPA := CircleTPA(Circles[0].Center.x, Circles[0].Center.y, Circles[0].Radius);
i := 0;
repeat
for i2 := 1 to High(Circles);
begin
if Round(Hypot(TheTPA[i].x - Circles[i2].Center.x, TheTPA[i].y - Circles[i2].Center.y)) > Circles[i2].Radius then
begin
SwapTPA(TheTPA[i], TheTPA[High(TheTPA)]);
SetLength(TheTPA, Length(TheTPA)-1);
dec(i);
break;
end;
end;
inc(i);
until i = High(TheTPA) + 1;
setlength(result, Length(TheTPA);
for i:= 0 to High(TheTPA) do
result[i] := TheTPA[i];
end;
by Heysus
program new;
{.include SRL/SRL.scar}
{.include SRL/SRL/misc/debug.scar}
type
TCircle = record
Center: TPoint;
Radius: integer;
end;
var
Circles: Array of TCircle;
TPA: TPointArray;
BMP, i, t: integer;
function CircleMatch(Circles: Array of TCircle): TPointArray;
var
x, y, x1, y1, x2, y2, i: integer;
begin
x2 := 9999999;
y2 := 9999999;
for i:=0 to High(Circles) do
begin
x1 := Max(x1, Circles[i].Center.x - Circles[i].Radius);
y1 := Max(y1, Circles[i].Center.y - Circles[i].Radius);
x2 := Min(x2, Circles[i].Center.x + Circles[i].Radius);
y2 := Min(y2, Circles[i].Center.y + Circles[i].Radius);
end;
//for debug only
for x:=x1 to x2 do
begin
FastSetPixel(BMP, x, y1, 16750899);
FastSetPixel(BMP, x, y2, 16750899);
end;
for y:=y1 to y2 do
begin
FastSetPixel(BMP, x1, y, 16750899);
FastSetPixel(BMP, x2, y, 16750899);
end;
for x:=x1 to x2 do
for y:=y1 to y2 do
begin
for i := 0 to High(Circles) do
begin
if Distance(x, y, Circles[i].Center.x, Circles[i].Center.y) > Circles[i].Radius then
break;
if i = High(Circles) then
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[High(Result)] := Point(x, y);
end;
end;
end;
end;
begin
SetArrayLength(Circles, 4);
Circles[0].Center := Point(203, 126);
Circles[0].Radius := 100;
Circles[1].Center := Point(162, 207);
Circles[1].Radius := 100;
Circles[2].Center := Point(281, 171);
Circles[2].Radius := 100;
Circles[3].Center := Point(173, 284);
Circles[3].Radius := 100;
ClearDebug;
BMP := LoadBitmap('C:\Users\Zach\Desktop\Untitled.bmp');
MarkTime(t)
TPA := CircleMatch(Circles);
Writeln('Took ' + IntToStr(TimeFromMark(t)) + ' ms');
DrawTPABitmap(BMP, TPA, 59900);
DisplayDebugImgWindow(400, 400);
DrawBitmapDebugImg(Bmp);
end.
by Bad Boy JH
type
TColorPoint = record
X, Y: Integer;
Color, R, G, B: Integer;
end;
TColorPointArray = Array of TColorPoint;
function rs_OnMinimap2(x, y: Integer): Boolean;
begin
Result := InCircle(x, y, MMCX, MMCY, 76);
end;
procedure SimplifyColors;
var
TheBitmap, ArrC, R, G, B, I, X, Y: Integer;
Box: TBox;
Colors: TColorPointArray;
begin
Box := MMBox;
SetLength(Colors, (Box.x2 - Box.x1) * (Box.y2 - Box.y1));
For X := Box.x1 to Box.x2 do
For Y := Box.y1 to Box.y2 do
if RS_OnMinimap2(X, Y) then
begin
Colors[arrC].Color := GetColor(X, Y);
Colors[arrC].X := X;
Colors[arrC].Y := Y;
ColorToRGB(Colors[arrC].Color, Colors[arrC].R, Colors[arrC].G, Colors[arrC].B);
Colors[arrC].Color := RGBToColor((Colors[arrC].R div 64) * 64, (Colors[arrC].G div 64) * 64, (Colors[arrC].B div 64) * 64);
Inc(ArrC);
end;
SetLength(Colors, ArrC);
TheBitmap := CreateBitmap(Box.x2 - Box.x1 + 1, Box.y2 - Box.y1 + 1);
CopyClientToBitmap(TheBitmap, Box.x1, Box.y1, Box.x2, Box.y2);
for I := 0 to High(Colors) do
FastSetPixel(TheBitmap, Colors[i].X - Box.x1, colors[i].y - Box.y1, Colors[i].Color);
DrawBitmapDebugImg(TheBitmap);
DisplayDebugImgWindow(Box.x2 - Box.x1 + 1, Box.y2 - Box.y1 + 1);
FreeBitmap(TheBitmap);
end;
And there's more. I'll search for it and unlock the thread once I'm done finding.