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 (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 arch...@mail-archive.com

Reply via email to