Re: Strange issue in stroking a bezier path
Re: Strange issue in stroking a bezier path
- Subject: Re: Strange issue in stroking a bezier path
- From: Andy Lee <email@hidden>
- Date: Sat, 05 May 2012 11:29:10 -0400
> On 2012-05-04, at 10:58 PM, Ken Thomases wrote:
>> Generally, if you actually want to draw just within the view's bounds, you would inset the rectangle by half the line width.
Alternatively, if you don't need the NSBezierPath for something else and you don't need alpha, you could use NSFrameRect(rect). From the docs:
<https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Miscellaneous/AppKit_Functions/Reference/reference.html#//apple_ref/doc/uid/20000695-SW33>
> Draws a frame around the inside of aRect in the current color and using the NSCompositeCopy compositing operation. The width is equal to 1.0 in the current coordinate system. Since the frame is drawn inside the rectangle, it will be visible even if drawing is clipped to the rectangle.
>
> Because this function does not draw directly on the line, but rather inside it, it uses the current fill color (not stroke color) when drawing.
I did not know until just now that it uses the fill color rather than the stroke color.
If you *do* need alpha, you could do it with
NSFrameRectWithWidthUsingOperation(rect, 1.0, NSCompositeSourceOver);
On May 5, 2012, at 10:41 AM, Peter Teeson wrote:
> Thanks so much Ken for that help. I am using NSInsetRect later on in my actual code for something else
> But I did not realize that the bounds stroke was straddling the view content edges.
> How did you learn that?
The docs mention it, though it's understandable that you didn't think to look for it since it *looked* like a hardware issue.
<https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsbezierpath_Class/Reference/Reference.html#//apple_ref/doc/uid/20000339-CHDECDGE>
> The drawn line is centered on the path with its sides parallel to the path segment. This method uses the current drawing attributes associated with the receiver.
--Andy
_______________________________________________
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