• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
One pixel width. One.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: One pixel width. One.
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Core Animation Deadlock
  • Next by Date: Re: Complex data for webservices
  • Previous by thread: Re: [solved] How to catch all mouse clicking (or avoid multiple click filtering in startTrackingAt)
  • Next by thread: Re: One pixel width. One.
  • Index(es):
    • Date
    • Thread