• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Stupid question: Flood Fill
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid question: Flood Fill


  • Subject: Re: Stupid question: Flood Fill
  • From: Jens Bauer <email@hidden>
  • Date: Wed, 26 Nov 2003 15:47:24 +0100

Hi Jon,

On Tuesday, November 25, 2003, at 10:44 PM, Jon Hull wrote:

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!

I've been thinking about that, but I may need to scale the non-extras (zoom in/out).
-But ofcourse, it can be done, and redrawn into the offscreen when zoomed as well.
My worst worry is that the offscreen image will use a lot of memory, and as the app supports multiple windows, it won't take long, before the user can't create any extra windows.
-But definitely, I'll look deeper into this, and try allocating the offscreen only when it's needed. :)

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).

This would indeed be tricky, when having a circle that was cut in 2 by a line somewhere in the circle.

-But maybe I can find a way, if I think more about it. It should be possible.

Thanks for the suggestions! =)


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.

References: 
 >Re: Stupid question: Flood Fill (From: Jon Hull <email@hidden>)

  • Prev by Date: Re: Validating values for NSArrayController
  • Next by Date: Adding drag-n-drop support to NSButton ?
  • Previous by thread: Re: Stupid question: Flood Fill
  • Next by thread: Re: Stupid question: Flood Fill
  • Index(es):
    • Date
    • Thread