# Fastest circles

int cir(SDL_Rect *twoPoints,SDL_Surface *dst,Uint32 couleur)
{
SDL_Rect barres;
double iCercle;
double plus=(double)(2/(double)(twoPoints->w));

for (iCercle=0; iCercle < 2*3.1416;iCercle=iCercle+plus)
{

putpixel(dst,abs(twoPoints->x)+twoPoints->w/2+(cos(iCercle)*twoPoints->w/2),

abs(twoPoints->y)+twoPoints->h/2+(sin(iCercle)*twoPoints->h/2),couleur);
}
}

that makes use of floating point math. hardly a screaming circle drawer
=) the bresenham one is all integer math, and makes use of the 8 way
symmetry of circles (x,y, -x,y, -x,-y, x,-y, y,x, -y,x, -y,-x, y,0x)

something like this:

[function stuff here] {
int xs,ys,t;
xs=0;

``````while(xs<=ys)
{
[plot all 8 symmetrical xs,ys points here]
if(t<=0)
t+=4*xs+6;
else
t+=48(sx-ys)+10;
++xs;
}
``````

}

it makes use of differential equations, so dont ask me why it works, it
just does =)

sorry to spam the board

chris–
Come away, O human child!
To the waters and the wild
With a faery, hand in hand,
For the world’s more full of weeping
than you can understand
–William Butler Yeats

[function stuff here] {
int xs,ys,t;
xs=0;

while(xs<=ys)
{
[plot all 8 symmetrical xs,ys points here]
if(t<=0)
t+=4*xs+6;
else
t+=48(sx-ys)+10;
++xs;
}
}

it makes use of differential equations, so dont ask me why it works, it
just does =)

I’ve been trying to figure it out, but I’m not sure I do. I think, however,
that it basically works by starting at the pixel at angle = 0, and after
drawing that, it moves to the next pixel to repeat. But where is the next
pixel? Well, you add the slope value to the previous pixel. The slope
initially is fully y direction and no x direction, but each successive pixel
has more x direction and less y direction. I think that’s pretty much the
theory behind this.

-Jason

----- Original Message -----
From: cwright@softpixel.com (Christopher P Wright <softpixel.com>)
To:
Sent: Wednesday, March 13, 2002 3:12 PM
Subject: [SDL] Re: fastest circles