Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TPAFromCircle2(Center: TPoint; Radius: Integer): TPointArray;
- var
- x,y,h,i: Integer;
- SqrRad: Single;
- begin
- SqrRad := Sqr(radius);
- SetLength(Result, Round(Sqr(radius+radius+1)));
- i := 0;
- for x := 0 to Radius do
- begin
- H := Round(Sqrt(SqrRad-Sqr(x)));
- for y := 0 to H do
- begin
- Result[i] := Point(center.x + x, center.y + y);
- Result[i+1] := Point(center.x + x, center.y - y);
- Result[i+2] := Point(center.x - x, center.y + y);
- Result[i+3] := Point(center.x - x, center.y - y);
- i := i+4;
- end;
- end;
- SetLength(Result, i);
- end;
- var
- bmp: TSCARBitmap;
- TPA: TPointArray;
- begin
- bmp := TSCARBitmap.Create('');
- bmp.SetSize(500, 500);
- TPA := TPAFromCircle2(Point(250, 250), 14);
- WriteLn(TPAToStr(TPA));
- bmp.SetPixels(TPA, 255);
- DebugBitmap(bmp);
- end.
Advertisement
Add Comment
Please, Sign In to add comment