#### Archived

This topic is now archived and is closed to further replies.

# Bezier Shape Fill

This topic is 5969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I moved to this thread from "Bezier Curves" because the fundemental nature of the subject changed: I''m writing a 2D animation system that draws everything as Bezier Curves and Bezier Shapes (that is, a closed set of cubic splines). I''m using forward differencing to get the points on the lines, but how does one fill in a closed shape? The only answer I have is to triangulate for each point and fill with the current color (I''m only interested in constant shading). But there are nuances that I need to be accounted for.... -Solstice deninet.com aeris.deninet.com "...I was given three choices, the earth, the stars, or..."

##### Share on other sites
Have a look on how I do it (in OpenGL). Or another way to do it would be quads/triangles..

" Do we need us? "

##### Share on other sites
That reminds me... I'm NOT looking for Bezier Patches, which are 3d. I'm looking for the actual algorithm to fill 2D Bezier shapes. I don't want to rely on OpenGL or any other library...

-Solstice

deninet.com
aeris.deninet.com

"...I was given three choices, the earth, the stars, or..."

[edited by - Solstice on March 18, 2002 6:53:19 PM]

##### Share on other sites
Hmm, you could do something like create an edge buffer that saves the starting and ending points for each scanline. Maybe use linked lists to create however many start/end pairs you need for each line. Otherwise, you wouldn''t be able to have something curve up and down (cause you''d only have one run per scanline).

Of course, you could just have an extra screen-sized buffer (actually it could just be an array of 0''s and 1''s) so you could draw the outline of the shape and then go along each scanline and every time you hit a pixel in your buffer set to 1, toggle drawing on or off. That way would be easier to code, and would be faster cause you wouldn''t have to dynamically allocate and delete linked lists, but in the end would probably be a lot slower cause you''d have to clear the buffer and loop through each pixel while drawing every shape.

Of course, those are just my first thoughts on it, but I hope it gives you some ideas.

-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

##### Share on other sites
HHHMMMMmmmmmmm...

I *do* like the edge buffer idea (ala Z-buffer), but your right, it could be very, very slow depending upon the size of the shape. This could be sped up a bit by not using booleans and instead using longs. This way, one could take advantage of the faster value setting of some instruction sets. Additionally, you could get the min/max x/y of the shape -- the extents box -- and reduce the size of the reset to only effected areas.

But in the end, does this still ignore cases like where a line segment curves back in on itself to form a loop? And about looping up, if the opposing line still progresses down, doesn''t the scanline then become oblique?

-Solstice

deninet.com
aeris.deninet.com

"...I was given three choices, the earth, the stars, or..."

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002284
×