Janilabo

Untitled

Sep 15th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.84 KB | None | 0 0
  1. function TPAFromCircle2(Center: TPoint; Radius: Integer): TPointArray;
  2. var
  3.   x,y,h,i: Integer;
  4.   SqrRad: Single;
  5. begin
  6.   SqrRad := Sqr(radius);
  7.   SetLength(Result, Round(Sqr(radius+radius+1)));
  8.   i := 0;
  9.   for x := 0 to Radius do
  10.   begin
  11.     H := Round(Sqrt(SqrRad-Sqr(x)));
  12.     for y := 0 to H do
  13.     begin
  14.       Result[i] := Point(center.x + x, center.y + y);
  15.       Result[i+1] := Point(center.x + x, center.y - y);
  16.       Result[i+2] := Point(center.x - x, center.y + y);
  17.       Result[i+3] := Point(center.x - x, center.y - y);
  18.       i := i+4;
  19.     end;
  20.   end;
  21.   SetLength(Result, i);
  22. end;
  23.  
  24. var
  25.   bmp: TSCARBitmap;
  26.   TPA: TPointArray;
  27.  
  28. begin
  29.   bmp := TSCARBitmap.Create('');
  30.   bmp.SetSize(500, 500);
  31.   TPA := TPAFromCircle2(Point(250, 250), 14);
  32.   WriteLn(TPAToStr(TPA));
  33.   bmp.SetPixels(TPA, 255);
  34.   DebugBitmap(bmp);
  35. end.
Advertisement
Add Comment
Please, Sign In to add comment