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;
ys=radius;
xs=0;
t=3-2*radius;
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