Re: [NSBezierPath clipRect] do not do what is says!
Re: [NSBezierPath clipRect] do not do what is says!
- Subject: Re: [NSBezierPath clipRect] do not do what is says!
- From: Eric Forget <email@hidden>
- Date: Thu, 26 Feb 2004 21:04:18 -0500
>
I don't know about translateOriginToPoint and rectClip, but the fuzzy
>
line is most like because anti-aliasing is on in the port. That's
>
great for objects in the document but for UI elements like guides or
>
resize rectangles that's not so cool. You can turn off anti-aliasing
>
as follows
>
>
NSGraphicsContext* context = [NSGraphicsContext currentContext];
>
BOOL antiAlias = [context shouldAntialias];
>
>
[context setShouldAntialias:NO];
>
>
// Do your drawing here
>
>
[context setShouldAntialias:antiAlias];
>
>
Also, you can use a stroke weight of 0.0 to indicate a device pixel
>
regardless of the scale factor on the view, for example:
>
>
[[NSColor blackColor] set];
>
[NSBezierPath setDefaultLineWidth:0.0];
>
[NSBezierPath strokeRect:rectToStroke];
Jeff,
Anti-aliasing is just part of the equation. If the line is at angle I want
the anti-aliasing. It is not me that set the line width both the user. A
line width of 0.0 is good only if you want smallest width for the device: a
thin line. However if the user really want 1 point then you still have the
problem.
There have been another thread about that (not sure if it was on Cocoa-dev
or Mac-dev) you may search "translateOriginToPoint" on
http://cocoa.mamasam.com. I'm not a specialist of the question, but the big
picture is that Quartz draws between the pixels. So when you stroke a line
with a width of 1 pixel it have to "touch" two pixels in grey instead of
black to approximate what you want. At high resolution, you won't see the
problem, but at 72 dpi the result is less than adequate (all depends of your
needs, for sure!). By translating the origin of 0.5, 0.5 you make sure that
Quartz draw directly on the pixels. It is important however to do that only
for screen device. You may check with [NSGraphicsContext
currentContextDrawingToScreen].
Eric
___________________________________________________________________
Eric Forget Cafederic
email@hidden <
http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.