• 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: [CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius]


  • Subject: Re: [CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius]
  • From: Bill Cheeseman <email@hidden>
  • Date: Tue, 02 Dec 2014 06:16:21 -0500

> On Dec 1, 2014, at 5:50 PM, Graham Cox <email@hidden> wrote:
>
>> On 2 Dec 2014, at 6:19 am, Bill Cheeseman <email@hidden <mailto:email@hidden>> wrote:
>>
>> Can anyone suggest another approach?
>
> Not another approach, but a possible alternative explanation. Antialiasing. Those curved corners will cause various nearby pixels to be rendered for antialiasing, and these may differ very slightly depending on all sorts of factors - line width, the colours used, the exact alignment of the path to the pixel grid, as well as the underlying curve algorithm. It's very hard to make two overlaid curves always hit exactly the same pixels even when using the same curve algorithm.
>
> Is there no way to avoid having to overlay two curves? Maybe clip the content to a round-cornered rect then finally draw the same path on top? (Not sure if that's actually what you want, it's a little hard to visualise from the verbal description).


Thanks, I'll look into these suggestions today.

Antialiasing issues seem unlikely because the exposed sliver of the underlying fill color seems too wide to be caused by antialiasing. But perhaps the slimmer sliver I see in some configurations could be explained by antialiasing.

I am looking into ways to avoid overlaying two paths. The problem is that Yosemite's NSVisualEffectView is very poorly documented. It appears that the only way to get "vibrancy" effects like those seen in the background fill region of Apple's application switcher is to give the NSVisualEffectView a dark "material" (which appears to be roughly equivalent to drawing a background fill color) and then filling a subview in front of it with another color. So both views need the same rounded corners in a transparent borderless window, which I do  by creating a mask image in the NSVisualEffectView and a mask layer in a CALayer/CAShapeLayer on the subview.

The stacking order of my window view hierarchy is this currently (today I will probably have to add another layer-hosting view between the inner visual effect view and the icon image view):

   window
      content view
         outer visual effect view filling window with rounded corners
            layer-hosting view filling window with rounded corners and returning YES in -allowsVibrancy
               inner visual effect view covering small center area of window
                  icon image view covering small center area of window and returning NO in -allowsVibrancy

--

Bill Cheeseman - 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: 
 >[CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius] (From: Bill Cheeseman <email@hidden>)
 >Re: [CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius] (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Layer-backed multiline text view rendering dim
  • Next by Date: TextEdit Document Icon
  • Previous by thread: Re: [CALayer cornerRadius] vs. [NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius]
  • Next by thread: Layer-backed multiline text view rendering dim
  • Index(es):
    • Date
    • Thread