• 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: NSImage inside(?) NSBezierPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage inside(?) NSBezierPath


  • Subject: Re: NSImage inside(?) NSBezierPath
  • From: Gregory Weston <email@hidden>
  • Date: Thu, 13 Sep 2007 10:26:29 -0400

Hell's Kitchen wrote:

Hello,
I've tried to make a simple custom NSView object as like event view in
iPhoto 2008. I've created the rounded rectangle with the method listed
above and tried to apply in it an NSImage.
Unfortunatly the NSImage does not fill correctly because my NSView
contains rounded angles while the image is a rectangle. Is there a way
to put this image *inside* the closed path? Or is there another way to
remove the borders of the image (it should be more diffucult I think).

Just to clarify: You're looking for a way to clip the NSImage with the path?


<http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaDrawingGuide/GraphicsContexts/chapter_3_section_3.html#// apple_ref/doc/uid/TP40003290-CH203-BCIIADBC>

This is the creation code of the view (here the result with the
problem: http://img178.imageshack.us/img178/2625/immagine2um5.png):

- (void)drawRect:(NSRect)rect {
	[NSGraphicsContext saveGraphicsState];
	NSBezierPath * path = [self bezierPathWithRoundRectInRect:rect];

This is a problem. There's no guarantee that the rect argument represents the whole view.


	[path stroke];
	[NSGraphicsContext restoreGraphicsState];
}

- (NSBezierPath *)bezierPathWithRoundRectInRect:(NSRect)aRect {
	...
	NSImage *im = [NSImage imageNamed:@"big"];
	[im drawInRect: [path controlPointBounds] fromRect: [path
controlPointBounds] operation:NSCompositeSourceOver fraction:1];

I also think it's weird that a method that appears to be an NSBezierPath factory happens to draw in the current context as a side- effect. I'd make this purely a factory (and a category on NSBezierPath) and use the resulting path as a clipping path from within the view's drawRect:.





_______________________________________________

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


  • Prev by Date: Re: popupbutton cell in an NSTableView displaying No Value
  • Next by Date: Re: NSBrowser background color
  • Previous by thread: Re: NSImage inside(?) NSBezierPath
  • Next by thread: connection kit
  • Index(es):
    • Date
    • Thread