• 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: Round Corners With BezierPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Round Corners With BezierPath


  • Subject: Re: Round Corners With BezierPath
  • From: Stephen Deken <email@hidden>
  • Date: Tue, 22 Aug 2006 21:46:41 -0500

NSRect				myBounds	=	[self bounds];
NSBezierPath		*Box;

[NSBezierPath setDefaultLineJoinStyle:NSRoundLineJoinStyle];
Box=[NSBezierPath bezierPathWithRect: myBounds];
[Box stroke];

A few observations:

* If you haven't set the line width, it will default to a width of 1.0. The rounding wouldn't be evident on such a line, since the radius of the rounding is equal to half of the width of the line.

* The stroke of a path is centered on the path. If you're outlining the bounds of an object, half of the line will be clipped away and you'll always wind up with a rectangle, with a stroke of 1/2 the width of the actual stroke.

There are two ways to go about it: one is to subtract half of the line width from the rectangle before stroking it:

	float lineWidth;
	NSRect myBounds = [self bounds];
	myBounds.origin.x += lineWidth / 2;
	myBounds.origin.y += lineWidth / 2;
	myBounds.size.width -= lineWidth;
	myBounds.size.height -= lineWidth;

The other way is to construct a path which actually consists of the lines and arcs corresponding to the rounded rect. I'm not sure what the most efficient solution is.

--sjd;
_______________________________________________
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


  • Follow-Ups:
    • Re: Round Corners With BezierPath
      • From: Tom Marchand <email@hidden>
References: 
 >Round Corners With BezierPath (From: Tom Marchand <email@hidden>)

  • Prev by Date: Re: NSWorkspace launchApplication fails on some apps
  • Next by Date: Re: Round Corners With BezierPath
  • Previous by thread: Round Corners With BezierPath
  • Next by thread: Re: Round Corners With BezierPath
  • Index(es):
    • Date
    • Thread