Re: erasing, redrawing NSBezierPath into and NSImage problem
Re: erasing, redrawing NSBezierPath into and NSImage problem
- Subject: Re: erasing, redrawing NSBezierPath into and NSImage problem
- From: Wilhelm Phillips <email@hidden>
- Date: Tue, 6 Jul 2004 10:52:21 -0700
Hi Steve,
Good to hear someone affirm some of my experiences with different
drawing methods.
You talked about using compositing operations. I was playing with that
yesterday evening after my posts. And using different methods I was
able to successfully remove the original bezierPath.
At this point it seems I can draw the labels correctly upon launch, and
clear the labels and redraw them upon resizing labelMatrix. However,
the redrawn shape is not resized as the coordinates would indicate.
So, when I redraw them, even if I have recreated the bezierPath with
new coordinates it still only draws the original shape from launch. No
matter how much I erase and redraw, the new path is never placed in the
image correctly.
Perhaps I am modifying the bezierPath in an incorrect way? I'm simply
removeAllPoints and redrawing it with new points into the image I'm
locked onto, but with no luck. I've even tried drawing into an
offscreen image and compositing that new image onto my label images,
but to no avail.
I'd like to be able to throw away the images as you suggested, but
since they are being used as labels in my labelMatrix I cannot release
them. And from the standpoint of reuse, I would like to be able to
redraw into the same image so I can continue to use my named label
image over and over again in various cells of my labelMatrix.
Will
On Jul 6, 2004, at 8:48 AM, Steve Sims wrote:
On 6 Jul 2004, at 01:03, Wilhelm Phillips wrote:
I'm pretty certain this has something to do with how I'm drawing the
bezierPath.
If I use your clearColor code with NSRectFill below I can clear the
entire image.
Yeah, NSRectFill doesn't seem to work the same way as filling
NSBezierPath objects... If memory serves I think it ignores the
opacity setting of the colour you're using it with.
If I set it to clearColor and try to fill just the bezierPath it
doesn't clear the image. Interesting.
That's because the clearColor is not opaque - it is fully transparent.
If you use it to fill then it actually results in nothing being
drawn. Same applies for using it to stroke paths.
This must also be leading to the reason why I cannot redraw correctly
back into the image.
Further suggestions?
I looked into doing some of this stuff a while back when I was writing
FontFX7. One possibility is to use multiple NSImages and use
compositing operations. You might want to take a look at the
CompositeLab sample code. If you want to clear parts of an NSImage
using an NSBezierPath to describe the area you wish to clear you
should draw that NSBezierPath in opaque black (or should that be
white?) in a new image and then use an "out" compositing operation to
cause the new path to be cleared from your source image.
A common reason for wishing to do this kind of thing is to get around
the problem of stroked lines overlapping their fills when using
transparent colours.
Using compositing however isn't entirely compatible with producing PDF
output files, since there are limitations on PDF compositing within
Quartz. For bitmapped output it's fine though.
Of course the alternative approach would be to simply throw the old
image away and draw a completely new one. This may be more efficient.
Steve
_______________________________________________
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.