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: Peter Teeson <email@hidden>
- Date: Sat, 05 May 2012 10:41:54 -0400
On 2012-05-04, at 10:58 PM, Ken Thomases wrote:
> On May 4, 2012, at 8:19 PM, Peter Teeson wrote:
>
>> - (void)drawRect:(NSRect)dirtyRect
>> {
>> // Drawing code here.
>> NSRect bounds = [self bounds];
>> NSBezierPath *path = [NSBezierPath bezierPathWithRect:bounds];
>> [path stroke];
>> }
>>
>> In the specific case of the Cinema Display having a resolution setting of 1280 x 800
>> the rectangle is not fully drawn every time. The top and right edges are missing.
>
> Well, I don't think you're drawing what you think you are. The bounds rect is outside of the view. It's the exterior boundary of the view.
> Now, when you stroke it, assuming you haven't changed the default line width of NSBezierPath,
> the stroke will be 1 point wide, half a point inside the view and half outside.
> This may involve anti-aliasing or, under HiDPI, perhaps a one-pixel wide line since that's half a point.
> It's probably up to the graphics driver to decide precisely how to render that half-point-wide line.
>
> Generally, if you actually want to draw just within the view's bounds, you would inset the rectangle by half the line width.
>
> Regards,
> Ken
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?
Also I find it strange that it just happened to work at all other resolutions under both HiDPI and standard.
So this may be an edge case (pun intended) in the driver in mapping to the actual hardware.
I followed your suggestion and inset bounds by 0.5 and it works fine.
Your contribution to my education made my day. Thanks a 1E6.
Peter
_______________________________________________
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