Re: Stupid question: Flood Fill
Re: Stupid question: Flood Fill
- Subject: Re: Stupid question: Flood Fill
- From: Jens Bauer <email@hidden>
- Date: Tue, 25 Nov 2003 05:06:50 +0100
Hi Public Look,
On Tuesday, November 25, 2003, at 04:43 AM, Public Look wrote:
On Nov 24, 2003, at 9:36 PM, Jens Bauer wrote:
How do I [path floodfill] ?
:)
I don't think you can. Flood fill is fundamentally a raster operation
and Quartz 2D is fundamentally a vector system.
Yes. And if I fill outside a shape, man, it'd take a long time for
flood fill to finish. :)
{snip}
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.
The trick is to store the vector commands efficiently and to redraw
as little as possible each time redrawing is needed.
I've tried various approaches, including a translucent view over the
view I'm drawing into, but no luck.. A vector view is a vector view,
that means slow.. :/
You will run into a particularly nasty side effect of the Quartz 2D
rendering system; performance of drawing degrades as the square of the
number of segments in a path.
Yep.
This results from the fact that Quartz has to test every segment for
intersection with every other segment in order to draw transparency
and anti-aliasing '"correctly". You are probably right that
NSBezierPath is way to slow, and all of the Quartz 2D (Core Graphics)
will also be too slow for the same reason. Your only hope if you
expect to use Quartz at all is to store individual line segments in
your application's data structures and draw them all separately.
I'm already doing that. :)
Unfortunately, the will make filling complex shapes very difficult.
Apple has succeeded in making an API for beautiful graphics but made
it virtually useless for anything complex due to its performance
characteristics.
Heh, it's quite funny, every simple platform has a flood fill, that's
easy to use, but... When it comes to Mac OS X, it's not available.
Ofcourse, there's Quickdraw, yes...but I'm losing the antialiasing
then. ;)
Would OpenGL render smoothly when printing ?
As far as I know, it is not possible to print with OpenGL at all short
of rendering to a giant image and printing that.
I heard (read) somewhere, that it was possible to generate a PDF from
an OpenGL view.. But I might have misunderstood that.
OpenGL is not device independent.
-OK, it seems my best solution would be...
1: Remember all draw-commands
2: Generate an offscreen image (for the antialiased version)
3: Generate a shadow offscreen-image for 'exact pixels' (no
antialiasing)
3: Output directly to the offscreen images
4: When flood-filling, fill to the 'exact pixels' offscreen image,
magic-wand it, and generate a vector-shape, use this vector-shape on
the antialiased offscreen with FillPath.
5: Copy the antialiased offscreen to the window
6: Draw the extras in the window
The worst will probably be to synchronize my own line drawing with the
antialiased line drawing, they might be a bit inaccurate, perhaps
enough to cause strange results. ;)
Thankyou for the suggestions and information. =)
Love,
Jens
_______________________________________________
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.