One pixel width. One.
One pixel width. One.
- Subject: One pixel width. One.
- From: Lorenzo <email@hidden>
- Date: Fri, 25 Apr 2008 09:19:40 +0200
I am trying to draw a line with 1 pixel width. No matter whether the view is
scaled or scrolled, I want to see a 1 pixel thick line. I scale the view
with
NSRect frameSize = [self frame].size;
NSSize newSize = NSMakeSize(frameSize.width / mScaleFactor,
frameSize .height / mScaleFactor);
[self setBoundsSize:newSize];
In the drawRect method I code
[[NSGraphicsContext currentContext] setShouldAntialias:NO];
[NSBezierPath setDefaultLineWidth:1.0 / mScaleFactor];
[NSBezierPath strokeLineFromPoint:NSMakePoint(0.0, 10.0
toPoint:NSMakePoint(10.0, 10.0)];
I works pretty well, but sometimes, depending on the scroll position or the
mScaleFactor, I get a line with 2 pixels width. Even with a mScaleFactor =
1, if I scroll the view, sometimes it looks with 2 pixels width. I even
tried to always set the width to 0.1 and mScaleFactor to always 1. Same
result. And I even tried to always set bounds Origin and bounds Size to
(int) values. Same result.
What do I miss?
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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