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

Re: Drawing Arcs


  • Subject: Re: Drawing Arcs
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Sun, 6 Jul 2003 13:11:02 +0100

On Sunday, July 6, 2003, at 05:26 am, Jim Crafton wrote:

Hi again,

I am trying to draw an arc given the following where:
x1, y1, x2, y2 define the bounding rectangle of the arc. The arc follows along the
ellipse that fits this rect
x3,y3 define the starting point which intersects with edge of arc and the center of rect
x4,y4 define the ending point which intersects with edge of arc and the center of rect
(for those with Win32 experience this is the same as Win32's Arc function)

I notice that NSBezierPath can draw arcs that trace along a circle, but not elliptical arcs. What's the best approach for tackling this?

You can use Bezier curves to approximate an arc; see http://www.tinaja.com/cubic01.asp (in particular, see http://www.tinaja.com/glib/bezarc1.pdf for a solution to the problem of fitting a cubic Bezier curve to a circular arc; remember that an elliptical arc is the same but for a constant factor). Also check out the comp.graphics.algorithms FAQ, at http://www.faqs.org/faqs/graphics/algorithms-faq/ (see section 4.04).

An alternative would be to approximate the arc with straight line segments (similar to the standard algorithms for rendering Bezier curves, in fact); for example, you could compute points on the arc (using the parametric formula for an ellipse), and continue to subdivide until you find a chord whose gradient is approximately constant, then render it as a straight line segment.

The one thing you *can't* do is to use a transformation to distort a circular arc, because in Quartz things like line width, dash patterns etcetera are _geometric_ attributes (on most other systems, Win32 included AFAIK, such things are _cosmetic_ attributes, which means that they are not affected by geometric transformation; Quartz is a more advanced graphics subsystem and as such, line styles etcetera *are* affected by any transformations in effect).

Kind regards,

Alastair.
_______________________________________________
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.

  • Follow-Ups:
    • BitBlts
      • From: Jim Crafton <email@hidden>
References: 
 >Drawing Arcs (From: Jim Crafton <email@hidden>)

  • Prev by Date: Re: Shift Key
  • Next by Date: Problem with NSNumberFormatter - no result even after searching the complete cocoa mamasam archive
  • Previous by thread: Drawing Arcs
  • Next by thread: BitBlts
  • Index(es):
    • Date
    • Thread