Skip to content

Instantly share code, notes, and snippets.

@rep-movsd
Created February 6, 2012 13:39
Show Gist options
  • Save rep-movsd/1752092 to your computer and use it in GitHub Desktop.
Save rep-movsd/1752092 to your computer and use it in GitHub Desktop.
procedure TForm1.DrawCircle3(cx, cy, r: Integer);
var
angle, angleInc : Extended;
i : integer;
x, y, sina, sinb, cosa, cosb, sinab, cosab : Extended;
begin
PaintBox1.Canvas.MoveTo(cx + r, cy);
angleinc := 360 / r;
sinb := Sin(angleinc / (180.0 / 3.14159));
cosb := Cos(angleinc / (180.0 / 3.14159));
sina := 0;
cosa := 1;
i := Round(360 / angleinc);
while i > 0 do
begin
sinab := sina * cosb + cosa * sinb;
cosab := cosa * cosb - sina * sinb;
x := r * cosab;
y := r * sinab;
sina := sinab;
cosa := cosab;
Dec(i);
PaintBox1.Canvas.LineTo(Round(x) + cx, Round(y) + cy);
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment