News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Drawing an ellipse

Started by japheth, June 24, 2006, 01:43:25 PM

Previous topic - Next topic

japheth


Hello,

does anyone know an implementation of an algorithm to draw an ellipse/circle in ASM (MASM, TASM, NASM) without using the FPU. Source should be free, but not GPL.


BogdanOntanu

Bresenham algorithm?
There is an implementatiion in Solar_OS latest release... but it is GPL.
But i guess that IF you understand the algoriithm THEN you can re implement it yourself with ease

In FACT it is easyer to draw a circel/elipse than it is to draw a line :)
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

japheth


> Bresenham algorithm?

Long ago I indeed implemented this thing for drawing lines, but it haven't come into my mind that it could also be used to draw an arc/ellipse/circle. Can it?

I've found a source in the meantime which I currently consider to use and convert. It is rather old and 16-bit ASM only.

Tedd

#3
Two integer methods come to mind (for a circle):
- using pythagoras' theorem (a^2 + b^2 = c^2), step through the x offsets (0..radius) and get a list of y offsets, and then plot all combinations of co-ordinates: (x,y), (y,x), (-x,y), (y,-x), (x,-y), (-y,x), (-x,-y), (-y,-x).
- bressenham's circle algorithm (similiar in sense to the line one.)

For an ellipse you might be able to get away with scaling a circle, though this will lose accuracy if you scale too much ('draw' the circle for the large radius, and then squash the axis for the smaller radius.)
You can make an ellipse by 'plotting' two circles, one for the larger radius, and one for the smaller. Then, depending on the orientation you want, you use only the (x,y) points from the large, and only (y,x) from the small. This will, however, only give you a horizontally or vertically oriented ellipse. So then you might require a rotation, which should still be possible without fp (but don't ask me how :bdg)
No snowflake in an avalanche feels responsible.