Re: Stupid question: Flood Fill
Re: Stupid question: Flood Fill
- Subject: Re: Stupid question: Flood Fill
- From: Jon Hull <email@hidden>
- Date: Tue, 25 Nov 2003 13:44:25 -0800
The approach you describe is basically the way every vector drawing
application works including Adobe illustrator, Corel Draw, and >
AutoCad.
Blast! The thing is that I need to clear the display, then draw
everything, then draw some extras. It's because I need to draw the
extras, I have to erase everything first, because the extras change
position each time the drawing is updated.
Why don't you draw all the non-extra stuff into an offscreen image.
Then in your drawRect method, draw the image and any extras. That way
you don't have to erase everything to draw the extras. Much faster!
The trick is to store the vector commands efficiently and to redraw
as little as possible each time redrawing is needed.
Exactly.
As for the flood fill (off the top of my head), do the work ahead of
time
in other words, whenever a new line is added check to see if it closes
a path. If it does then make an NSBezierPath of that closed path, and
store it in a separate structure. Then when you need to fill just go
through your list of closed paths, and see which one contains it. (It
is a little more complicated than that, but you get the idea).
Thanks,
Jon
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.