• 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: Removing or ignoring "lineWidth" property of an NSBezierPath instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing or ignoring "lineWidth" property of an NSBezierPath instance


  • Subject: Re: Removing or ignoring "lineWidth" property of an NSBezierPath instance
  • From: Graham Cox <email@hidden>
  • Date: Tue, 28 Apr 2009 10:13:30 +1000


On 28/04/2009, at 3:54 AM, Tobias Zimmerman wrote:

I think that, at best, the documentation is ambiguous. It would be clearer
specifically saying "If no value was set explicitly for the receiver, this
method [lineWidth] returns the default line width ->at the time the receiver
was created<-" I may file a RADR on that.

Well, it didn't seem too ambiguous to me - but then again additional clarification wouldn't hurt.



It is further confusing because the actual effect of the lineWidth property
is dependent on the view in which the drawing takes place -- that is, a line
width of "1.0" in one view will not necessarily appear the same width in a
separate view that has a different dot-pitch, pixel ratio, etc.


That's not the case. The whole point of Quartz is that it is resolution independent. 1.0 points always means 1.0 points, and when that's rasterized it will set as many pixels as necessary on the device it's drawing to. Of course if the resolution is such that the smallest pixel is effectively 2 points, Quartz can only fake it by drawing the 2pt pixel at half brightness. This happens when you use a line width of, say 0.5, and the smallest pixel is 1.0 points. However the appearance of the line will be consistent, within reason (very coarse resolutions obviously cause problems with this approach, but these days 72dpi is definitely a minimum). Don't confuse points and pixels. While by default without scaling, on screen there is a 1:1 correspondence between them they are completely independent.

The only exception to this is when you specify a line width of 0 with NSBezierPath - that will be resolution dependent but it's a special case, and doesn't apply to the CGPath functions. If your aim is to always draw a 1-pixel wide line no matter what the target resolution is, a line width of 0 will do that. If your aim is to always draw a 2- pixel line, you'd have to calculate the necessary line width knowing the resolution of the device and scaling appropriately, as there's no built-in way to force this kind of resolution dependence.

If you want to use a fixed resolution regardless, you could create a suitable bitmap and draw into that, then draw that to the target device as needed (and turn off anti-aliasing for that genuine Windows 3.1 look).

Where a drawn line width will also appear differently is when a view is scaled (i.e. the view context has a scaling transform in force), but then you'd expect that I would have thought.

--Graham


_______________________________________________

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: 
 >Re: Removing or ignoring "lineWidth" property of an NSBezierPath instance (From: Tobias Zimmerman <email@hidden>)

  • Prev by Date: Re: NSTextView re-implementing word wrapping
  • Next by Date: QTMovie -updateMovieFile file size issue
  • Previous by thread: Re: Removing or ignoring "lineWidth" property of an NSBezierPath instance
  • Next by thread: NSOpenPanel listing .app's and Mac OS X executables
  • Index(es):
    • Date
    • Thread