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

Re: Merging BezierPath


  • Subject: Re: Merging BezierPath
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Wed, 2 Jul 2003 15:30:02 +0100

On Wednesday, July 2, 2003, at 12:29 pm, Aidas Dailide wrote:

Hi,

I am trying to draw a simple bezier path. Here is the code i use:
path=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(sRect.origin.x- 5,sRect.origin.y,10,sRect.size.height)];
[path appendBezierPathWithRect:NSMakeRect(sRect.origin.x,sRect.origin.y,sRect .size.width,sRect.size.height)];
[path appendBezierPathWithOvalInRect:NSMakeRect(sRect.origin.x+(sRect.size.wi dth-5),sRect.origin.y,10,sRect.size.height)];

The problem is when i am trying to us stroke command. If i stroke my path then two ovals and rects are stroked. This is what it has to happen, but i want to stroke those three as one. Is it possible to somehow merge those three paths into one?

I'm not sure if I follow exactly what you're trying to do; my guess is that you're trying to draw a bar with elliptical ends, something like:

A B
A' ,----------------------------------, B'
/ \
/ \
F | | C
| |
\ /
\ /
E' '----------------------------------' D'
E D

If you're after doing that, then you probably want to use the moveToPoint:, lineToPoint: and curveToPoint:controlPoint1:controlPoint2: methods rather than drawing with rectangles and ovals. Something like

[path moveToPoint:A];
[path lineToPoint:B];
[path curveToPoint:D controlPoint1:B' controlPoint2:D'];
[path lineToPoint:E];
[path curveToPoint:A controlPoint1:E' controlPoint2:A'];
[path closePath];

should do the trick (this is, of course, pseudo-code... for one thing, ObjC doesn't allow dashed variable names). You can control the curvature by repositioning the control points A', B', C' and D'. Since you're drawing, I'm assuming that you only need a visual approximation to an ellipse; otherwise you'll need some mathematics ;-)

If you're after a solution to the more general problem of merging arbitrary Bezier paths together (or performing other Boolean path operations), then as far as I know there isn't any (non-proprietary) code out there that can do Boolean operations on paths containing curve segments. (I started working on this problem a while back, but I haven't had the time to finish it off yet.)

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.

References: 
 >Merging BezierPath (From: Aidas Dailide <email@hidden>)

  • Prev by Date: Re: Accessing Aqua metrics without Carbon
  • Next by Date: Re: NSOpenGLView. How does it work?
  • Previous by thread: Merging BezierPath
  • Next by thread: -awakeFromNib, application releasing...
  • Index(es):
    • Date
    • Thread