Fill Circles (was fastest circles)

The code for the fast circles works a treat :slight_smile: Thanks to those who
contributed it :slight_smile:

Anyone know how to do filled ones? Or even ellipses?

On a side note… I know that stuff like SDL_gfx exists, but for people like
me that only want single functions like circle drawing, how about we get a
code snippets(?) section set up on the main SDL site…? I only suggest it
because I looked for a few days for circle drawing code, but couldn’t make
head or tail of it to try and rewrite it for SDL. Anyone think this is a
good idea?

The code for the fast circles works a treat :slight_smile: Thanks to those who
contributed it :slight_smile:

Anyone know how to do filled ones? Or even ellipses?

Filled ones you could just draw lines from the point (x,y) to (0,y) instead
of just plotting a pixel. We are assuming the circle is centered on (0,0)
here, btw. Ellipses I’m not quite sure about. Bresenham’s algorithm might
still work modified, but not sure offhand how to modify it.

On a side note… I know that stuff like SDL_gfx exists, but for people
like
me that only want single functions like circle drawing, how about we get a
code snippets(?) section set up on the main SDL site…? I only suggest it
because I looked for a few days for circle drawing code, but couldn’t make
head or tail of it to try and rewrite it for SDL. Anyone think this is a
good idea?

I dunno. Can’t we just all go to SDL_gfx to see code snippets like this? :slight_smile:

What I think would be better really is a centralized website that has these
kinds of algorithm samples and explains the theory behind them easily.
Probably isn’t quite right to have on the SDL site, though. But then again,
it does make sense too.

-Jason

----- Original Message -----
From: sweenes@fnb.co.uk (Steven Sweeney))
To:
Sent: Thursday, March 14, 2002 5:09 AM
Subject: [SDL] RE: Fill Circles (was fastest circles)

| What I think would be better really is a centralized website that has these
| kinds of algorithm samples and explains the theory behind them easily.
| Probably isn’t quite right to have on the SDL site, though. But then again,
| it does make sense too.

It would be good to have some website that told you all about graphics
programming. One that had the algorithms, theory, and did it all in a
totally language and OS independant way.On Thu, Mar 14, 2002 at 05:57:16AM -0500, Jason Hoffoss wrote:

–
I will not pledge allegiance to Bart
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

Ellipses can be drawn using midpoint algorythm too, but it can only
draw those, which have the focal points in the direction of either x or
y axis.
The other variants of ellipses will require floatingpoint math.

If you want to know more about primiteve drawing just buy “Computer
Graphics” from pretice hall and it will explain everything in detail
from line drawing to ray-tracing.On 2002.03.14 12:09 “Sweeney, Steven (FNB)” wrote:

The code for the fast circles works a treat :slight_smile: Thanks to those who
contributed it :slight_smile:

Anyone know how to do filled ones? Or even ellipses?

At 17:27 14.03.2002 +0200, you wrote:

The code for the fast circles works a treat :slight_smile: Thanks to those who
contributed it :slight_smile:
Anyone know how to do filled ones? Or even ellipses?

Ellipses can be drawn using midpoint algorythm too, but it can only draw
those, which have the focal points in the direction of either x or y axis.
The other variants of ellipses will require floatingpoint math.

If you want to know more about primiteve drawing just buy “Computer
Graphics” from pretice hall and it will explain everything in detail

from line drawing to ray-tracing.

I would like to add, that programming is about understanding the algorithm
and then being able to translate it into a certain language. So I suggest
you read this book instead of just copying-in some code snippets, as this
is not only lame, this makes you something else than a programmer (or
better: a real Bitschmied (don’t have a translation to english here,
'cause babelfish once again doesn’t really work)!).
Just using code from somewhere needs a reason like: it is system
specific. F.E: it’s no prob to take code from the SDL-manpages, cause this
is code for you, to know how to use SDL.
Regards,
St0fF.>On 2002.03.14 12:09 “Sweeney, Steven (FNB)” wrote:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

At 17:27 14.03.2002 +0200, you wrote:

The code for the fast circles works a treat :slight_smile: Thanks to those who
contributed it :slight_smile:
Anyone know how to do filled ones? Or even ellipses?

Ellipses can be drawn using midpoint algorythm too, but it can only
draw those, which have the focal points in the direction of either x
or y axis.
The other variants of ellipses will require floatingpoint math.

If you want to know more about primiteve drawing just buy “Computer
Graphics” from pretice hall and it will explain everything in detail

from line drawing to ray-tracing.

I would like to add, that programming is about understanding the
algorithm and then being able to translate it into a certain
language. So I suggest you read this book instead of just copying-in
some code snippets,…

This book is some what special in that that it’s not filled with
sources, because it’s a course book for University I think.
But nevertheless it’s great reading if you are interested in primitive
GFX rendering.

PS. For the Filled circle algo that I posted. There is small error that
I made when converting the unfilled one to draw filled circles. The
last two line commands in the while loop need to be after the "p+=xx;"
line not inside the if. And just found out while testing, that the line
commands after the loop are unnecessary. This results for exactly one
drawn line for each rendered scanline.On 2002.03.16 02:47 St0fF 64 wrote:

On 2002.03.14 12:09 “Sweeney, Steven (FNB)” wrote: