• 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: NSBezierPath Problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBezierPath Problems


  • Subject: Re: NSBezierPath Problems
  • From: Shawn Erickson <email@hidden>
  • Date: Sun, 29 Sep 2002 19:04:52 -0700

On Sunday, September 29, 2002, at 06:27 PM, King Chung Huang wrote:

Hi,

I'm implementing a custom NSControl/NSCell, and I'm having trouble with
drawing the widget in my NSCell's drawWithFrame:cellFrame inView:controlView
function. This is the first time I've used NSBezierPath.

In my code, I've set the line width to 1.0 using [NSBezierPath
setDefaultLineWidth:1.0]. Then, I draw a series of lines. However, some of
my lines are coming up with widths of 2 pixels, while others are 1 pixel as
expected.

For example,

[NSBezierPath strokeLineFromPoint:NSMakePoint(minX + 11, minY)
toPoint:NSMakePoint(minX + 11, minY + 6)];
[NSBezierPath strokeLineFromPoint:NSMakePoint(maxX - 11, minY)
toPoint:NSMakePoint(maxX - 11, minY + 6)];

Is drawing lines that are two pixels wide.

I found a reference to a similar encounter at
<http://lists.apple.com/archives/cocoa-dev/2001/Jun/14/ stupidcodeorbuginnsbe
zie.txt>. However, the only response to the post was a message that a bug
was filed against Quartz.

Another problem I've been having is that the lines that do get drawn seem to
be at < 100% opacity. The code I used to set the color is [[NSColor
colorWithDeviceRed:0.24 green:0.24 blue:0.24 alpha:1.00] set]. However, when
I draw, the DigitalColor Meter clearly shows that the resulting line isn't
nearly as dark as I'd specified, and the areas where the lines overlap are
darker than the rest of the line. If I set the line width to 2.0, then
they're the correct color, but I'm trying to get 1 pixel lines!

Quartz drawing has the point grid centered differently then you may be expecting. The center of a point is half way between whole numbers. In other words (0.5,0.5) would be in the center of a screen pixel framed by (0, 0, 1, 1).

So in the above try 11.5 and 6.5 otherwise Quartz is attempting to simulate the line you are requesting (this also causes the transparent lines) one that doesn't go through actual pixels directly.

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSBezierPath Problems (From: King Chung Huang <email@hidden>)

  • Prev by Date: Re: [newbie] Handling a preferences window
  • Next by Date: NSFileHandle readInBackgroundAndNotify
  • Previous by thread: Re: NSBezierPath Problems
  • Next by thread: Left mouse events in a window
  • Index(es):
    • Date
    • Thread