Re: NSBezierPath geometry question...
Re: NSBezierPath geometry question...
- Subject: Re: NSBezierPath geometry question...
- From: Heinrich Giesen <email@hidden>
- Date: Mon, 11 Apr 2005 20:49:39 +0200
On 11.04.2005, at 18:48, Serge Meynard wrote:
You're right, I guess I misunderstood the doc about how that method
works... Reading it again it makes more sense now, and is actually
Yes, the text is difficult to understand. Therefore I used one of my
old PostScript books which showed a clear description of the arcto
function with a picture and an example. And this is the result in
Objective-C for drawing a rect with rounded corners
- (
void) drawRoundedRect:(NSRect)aRect inView:(NSView *)aView
{
NSBezierPath *path;
float radius =
9.0; // looks good
NSPoint topLeft, topRight, bottomRight, bottomLeft, startPoint;
topLeft = NSMakePoint( aRect.origin.x, aRect.origin.y );
topRight = NSMakePoint( topLeft.x + aRect.size.width, topLeft.y );
bottomRight = NSMakePoint( topRight.x, topRight.y + aRect.size.height );
bottomLeft = NSMakePoint( topLeft.x, bottomRight.y );
startPoint = NSMakePoint( topLeft.x, topLeft.y + radius );
path = [NSBezierPath bezierPath];
[path moveToPoint:startPoint];
[path appendBezierPathWithArcFromPoint:topLeft
toPoint:topRight radius:radius];
[path appendBezierPathWithArcFromPoint:topRight
toPoint:bottomRight radius:radius];
[path appendBezierPathWithArcFromPoint:bottomRight
toPoint:bottomLeft radius:radius];
[path appendBezierPathWithArcFromPoint:bottomLeft
toPoint:topLeft radius:radius];
[path closePath];
[path setLineWidth:
1];
[aView lockFocus];
[[NSColor redColor] set]; // whatever you want
[path stroke];
[aView unlockFocus];
}
--
Heinrich Giesen
email: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden