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

Re: Round Rect


  • Subject: Re: Round Rect
  • From: Gregory Weston <email@hidden>
  • Date: Thu, 30 Mar 2006 05:53:03 -0500

Henry McGilton asked:

The traditional Mac OS RoundRect has elliptical corners,
though, rather than circular. Here's the implementation I use.

Well, I was following this thread in a desultory fashion until your statement about traditional RoundRect has elliptical corners caught my eye.

(1)  Is that true even for 'rectangles' that are actually square?

(2)  Do the x and y radii of the ellipse vary with the width and
      height of the rectangle?

and Greg Herlihy responded:

Round corners are elliptical - because a circle is an ellipse (just as a
square is a rectangle). So technically, yes, the corners of a QuickDraw
RoundRect were drawn with ellipses - but those ellipsis were always circles.

Which is, bluntly, wrong. The answer to the questions is that the geometry of the underlying rectangle doesn't matter beyond imposing upper limits. As with the sample code I included, the traditional roundrect is effectively an ellipse aligned with the Cartesian plane whose major and minor radii are independently specified by the developer. Then it's bisected along both axes, the curves thus defined translated to their respective corners of the specified rectangle and connecting lines are created as necessary along the edges of that rectangle.


As an example, imagine a rectangle 100 pixels wide and 20 tall. Now specify a roundrect where the corner radius parallel to the X axis is 50 and that parallel to the Y axis is 3. You'll end up with a figure that has two straight (vertical) edges, no straight horizontals and corners that aren't even vaguely circular.

Despite being presented as a replacement, the code on the page Greg cites isn't functionally equivalent to the Toolbox roundrect routines. The deviation is described (although not acknowledged) in this statement regarding CGContextAddArcToPoint: "If the current point and the first tangent point of the arc (the starting point) are not equal, Quartz appends a straight line segment from the current point to the first tangent point." Old QD roundrects don't do that.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: distribution app (was: disk image making)
  • Next by Date: Handling menu actions in doc-based apps
  • Previous by thread: Re: Round Rect
  • Next by thread: Hanging Indentation in NSTextField
  • Index(es):
    • Date
    • Thread