Your instinct is right: High quality graphics libraries do the filling usually the "mathy" way and not via an auxiliary bitmap and flood fill. For a circle the filling algorithm is not overly complex. Filling an arbitrary polygon is somewhat more difficult.

Look into the versions of the Bresenham algorithm for circles and ellipses for a fast way to find the border points. That saves you a lot of sin and cos calls and you might even get away with pure integer arithmetic.

For polygon filling I would (as always) start with a Google search. There are quite some interesting algorithms around for that.

Good luck; you chose an interesting subject.

11,716,249 members (91,530 online)

Email

Password

Sign in using

—SA

You can work out the slope of each edge of the polygon, before calculating all of the points that lie on them. So long as the vertexes have been sorted first (in order of y value), it's farly easy to loop through all of the y values of the polygon, calculating a left boundary and a right boundary. You then iterate through this list, drawing a horizontal line between the left and right boundaries. This page may provide some insight: Gouraud & Phong shadng polygons