## Re:Formula for drawing circles

##### Quote

Francois Smit wrote:

> Hi.

> I'm looking for a formula to draw circles in the fastest time.

What circles ? What sizes ?

##### Quote

> I don't want to use the circles in Delphi.

Why ? They might be hardware accellerated ,and drawing circles

with accessing pixels will allways be slower.

Ok , i know of 2 possibilites :

1) draw 1/8 of a circle , calculating the points with

for x:=0 to numberofpixels

setpixel(basex+trunc(sin(pi/4/numberofpixels*x)*radius,

basey+trunc(cos(pi/4/numberofpixels*x)*radius)

and add 7 more "setpixels" mirroring the remaining 7/8s of the

circle

2) Phytagoras : radius=sqrt(sqr(x)+sqr(y)) , solves to

for y:=-radius to radius to

begin

max:=sqrt(sqr(radius)-sqr(y))

for x:=-max to max do

setpixel(basex+x,basey+x)

end;

3) for lots of fast circles , of same size , use one of the above to

fill a table , and use this table to draw the circles.

hope that helps ....

Andreas