Re: A86: polygons


[Prev][Next][Index][Thread]

Re: A86: polygons





>since we seem to have nothing to talk about, does anyone have any 
>ideas
>on how to draw a polygon and fill it with a certain color (black and
>white to start)?

I haven't made the code, but I can give you theory.

To draw the polygon just draw lines from vertex to vertex, and then draw
a line from the first vertex to the last.

To fill the easiest way is probably scan line somethin-or-other:

For every line of the screen (scan line), there will be a series of
points where the polygon was drawn to the screen.  If there is an even
number of points, fill the line between the 1st and 2nd, 3rd and 4th and
so on.  If there is an odd number of points, the line is on a part of the
polygon that either is off the screen, or is on a pointy edge. The only
way I know to tell the difference is to look at the y-values of the
lines.  If there are lines to be filled above and below the odd line,
then the odd line should be filled, otherwise it shouldn't.  To do this
there would have to be some table of values.  Notice this works on convex
polygons, I don't know about concave or complex.

Also this only works with a frame buffer.

An example:
(20*14) screen

00000000000000000000
00000001000000000000<-Pointy edges of polygons don't get filled
00000010010000000000<-Even number so the 2 00's would be filled
00000100000100000000<- "
00001000000001000000<- "
00010000000000010000<- "
00100000000000000100<- "
00001000000000000001<- "
00000010000000000000<-Looks the same as a pointy edge,
00000000100000000000<-but should be filled.
00000000001000000001<-Even
00000000000010000010<- "
00000000000000100100<- "
00000000000000001000<-Pointy edge
00000000000000000000


Sam




_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


References: