• 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
Re: One pixel width. One.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One pixel width. One.


  • Subject: Re: One pixel width. One.
  • From: Graham Cox <email@hidden>
  • Date: Fri, 25 Apr 2008 17:34:44 +1000

Try offsetting the final result by 0.5, so that you draw the actual pixel, not anti-alias across two.

G.


On 25 Apr 2008, at 5:19 pm, Lorenzo wrote:
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

_______________________________________________

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


References: 
 >One pixel width. One. (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: Complex data for webservices
  • Next by Date: Re: Failure on unarchiving a NSBezierPath
  • Previous by thread: One pixel width. One.
  • Next by thread: Re: One pixel width. One.
  • Index(es):
    • Date
    • Thread