views:

87

answers:

1

What I want is to create a vector drawing program with layers, but to avoid using transparency / opacity, I want to draw each shape from lowest layer to highest layer onto a single bitmap. For the filling, I want to floodfill the shape. My issue is that, if I have a shape that is drawn then floodfilled, then the next shape overlaps it a bit and that new shape's border is the same as the other one's then floodfill will only partially fill it. Is there a way given a shape's coordinates that I can find the actual bounds for floodfill rather than use a target color? Thanks

+1  A: 

Floodfill will not work for what you want... Unless, you make one of the following:

Option 1: Use the floodfill in other part of the memory, and then blit the shape using a mask to the place where you want, since you said you wanted to avoid transparency, this option is sort of crossed out... (altough I still recommend it, really, it is not hard to make a if that checks if that pixel is or not to be copied)

Option 2: Use only basic shapes, that you can fill easily without using floodfill, filling them with horizontal lines with the starting and endpoint being between the two end pixels of each line of the shape. That would be for squares, circles...

Option 3: Same as option 2, but allowing arbitrary triangles.

Option 4: Same as 3, but allowing you to read a list of points, and compose the object with several rectangles, so you can make any arbitrary shape (even convex ones). That one would be really hard to implement properly (specially convex shapes).

speeder