[SDL] polygon filling

Arne Claus priest at seraphim.info
Sun Sep 22 01:27:00 PDT 2002

> Anybody know of a library that handles arbitrary polygon filling?  I 
> have only found them for lines, triangles, circles etc. and I really 
> don't want to write my own.  :-)

Basically you do the same thing as for lines or circles. You iterate 
over the edge-pixels and draw a horizontal line from one pixel to the 
other. Well - this works for konvex Polygons, but not for concav 
(S-Shape) or intersecting polygons (5-edged star).
To write this on your own would be rather tricky (I did once - scaaary 
thing =) and I guess the way Alan suggested is probably one of the 
smoothest, because triangles are always convex. Anyways finding the 
triangles is still a bit tricky, too.

Search google for "polygon filling" - there are quite many tutorials on it.


More information about the SDL mailing list