Re: NSImage inside(?) NSBezierPath
Re: NSImage inside(?) NSBezierPath
- Subject: Re: NSImage inside(?) NSBezierPath
- From: "Alan Smith" <email@hidden>
- Date: Thu, 13 Sep 2007 17:59:05 -0400
Hey,
To aid in clarity I will code what has been suggested.
- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
NSBezierPath *path = [self bezierPathWithRoundRectInRect: bounds];
[NSGraphicsContext saveGraphicsState];
[[NSColor redColor] set];
[path stroke];
[path addClip];
[image drawInRect: bounds fromRect: NSZeroRect fraction: 1.0
operation: NSCompositeSourceOver];
[NSGraphicsContext restoreGraphicsState];
}
I am writing all this from memory, it has been a while since I've
needed to draw an image so the order of the draw parameters may not be
correct. Passing NSZeroRect as the "fromRect" argument tells NSImage
that you want to draw the whole image, this prevents you from call -
[NSImage size] and making your own rect that is the same size as the
image.
Peace, Alan
--
My blog: cocoalatte.info
// Things I've said -------------------------
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that personal beliefs are not something to
argue or fight over, it shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden