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: Mon, 5 Jul 2004 21:23:45 -0700
Using your code I did manage to clear the images. However, I was not
able to draw back into them with the modified bezierPath and correct
size.
I'm wondering if this has anything to do with when/how I'm allocating
the images or how I'm drawing them. Or maybe it has something to do
with redrawing the bezierPath. The drawLabels routine runs at
awakeFromNib and then each time my windowDidResize and each time the
user adjust the column width of labelMatrix.
Following is my code for drawing the labels:
- (void)drawLabels
{
bezierPath = [NSBezierPath bezierPath];
// here is where I draw theBezierPath
// based on cellHeight, cellWidth of labelMatrix, etc.
someLabel = [[NSImage alloc] initWithSize:NSMakeSize(cellWidth,
cellHeight)];
[someLabel lockFocus];
// using clearColor to erase image
NSRect imageRect;
imageRect.origin = (NSPoint){0.0f,0.0f};
imageRect.size = [someLabel size];
[[NSColor clearColor] set];
NSRectFill(imageRect);
// redraw modified bezierPath
someLabelColor = [NSColor colorWithCalibratedRed:0.0 green:0.5
blue:1.0 alpha:0.4];
[someLabelColor set];
[bezierPath fill];
[someLabel unlockFocus];
[labelMatrix setNeedsDisplay: YES];
}
Will
On Jul 5, 2004, at 8:07 PM, Louis C. Sacha wrote:
Hello...
Have you tried using NSRectFill() to erase the image?
After you lock focus on your image, use the NSRectFill() function to
fill it with the "clear" color (uses the NSCompositeCopy compositing
mode, which replaces the pixels with the new color).
NSRect imageRect;
imageRect.origin = (NSPoint){0.0f,0.0f};
imageRect.size = [yourImage size];
[[NSColor clearColor] set];
NSRectFill(imageRect);
Hope that helps,
Louis
_______________________________________________
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.