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 PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to