NSBezierPath stroke width on retina/nonretina

  • Hi,

    found a really weird issue with some very basic drawing, and have no idea whats going wrong (or what I missed:)). Basically I've a subclass of NSButton and NSButtonCell with some basic custom drawing. I do a 1px width stroke after all around the button, which is looks cool on my computer having retina display, but it looks really fat on a normal display (please check out the attach picture).
    That is how do the stroke:

        [[NSColor blackColor] setStroke];
        [_bezelPath setLineWidth:1.0f];
        [_bezelPath stroke];

    Any idea is very welcomed,

    Thanks,

    Tamas
  • On 26 Apr 2013, at 9:51 AM, Tamas Nagy <tamas.lov.nagy...> wrote:

    > Hi,
    >
    > found a really weird issue with some very basic drawing, and have no idea whats going wrong (or what I missed:)). Basically I've a subclass of NSButton and NSButtonCell with some basic custom drawing. I do a 1px width stroke after all around the button, which is looks cool on my computer having retina display, but it looks really fat on a normal display (please check out the attach picture).
    > That is how do the stroke:
    >
    > [[NSColor blackColor] setStroke];
    > [_bezelPath setLineWidth:1.0f];
    > [_bezelPath stroke];
    >
    > Any idea is very welcomed,

    You don't say, but are the lines in your Bézier path drawn on integral coordinates (e.g., 10, 10, with no fractions)? The Quartz coordinate system puts points _between_ pixels.

    A line going down a series of integral pixels (10.0, 10.0) will be drawn as 50% gray on either side. It looks wide and dim. If you offset them by 0.5 (10.5, 10.5), the line will go straight down the pixels, and be shown thin and black.

    — F

    --
    Fritz Anderson
    Xcode 4 Unleashed: 4.5 supplement for free!
    http://www.informit.com/store/xcode-4-unleashed-9780672333279
  • Thanks for the tip! I was using integral coordinates without fractions, adding

    _newframe = NSInsetRect(_newframe, 0.5f, 0.5f);

    fixed the issue!

    Thanks!

    Tamas

    On Apr 26, 2013, at 5:28 PM, Fritz Anderson <fritza...> wrote:

    > On 26 Apr 2013, at 9:51 AM, Tamas Nagy <tamas.lov.nagy...> wrote:
    >
    >> Hi,
    >>
    >> found a really weird issue with some very basic drawing, and have no idea whats going wrong (or what I missed:)). Basically I've a subclass of NSButton and NSButtonCell with some basic custom drawing. I do a 1px width stroke after all around the button, which is looks cool on my computer having retina display, but it looks really fat on a normal display (please check out the attach picture).
    >> That is how do the stroke:
    >>
    >> [[NSColor blackColor] setStroke];
    >> [_bezelPath setLineWidth:1.0f];
    >> [_bezelPath stroke];
    >>
    >> Any idea is very welcomed,
    >
    >
    > You don't say, but are the lines in your Bézier path drawn on integral coordinates (e.g., 10, 10, with no fractions)? The Quartz coordinate system puts points _between_ pixels.
    >
    > A line going down a series of integral pixels (10.0, 10.0) will be drawn as 50% gray on either side. It looks wide and dim. If you offset them by 0.5 (10.5, 10.5), the line will go straight down the pixels, and be shown thin and black.
    >
    > — F
    >
    > --
    > Fritz Anderson
    > Xcode 4 Unleashed: 4.5 supplement for free!
    > http://www.informit.com/store/xcode-4-unleashed-9780672333279
    >
previous month april 2013 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Go to today