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

Re: drawing arrows


  • Subject: Re: drawing arrows
  • From: Rob Ross <email@hidden>
  • Date: Wed, 12 Jul 2006 16:00:40 -0700

I played around with this demo:

http://www.alastairs-place.net/archives/000037.html

since I needed to draw some arrows myself and it's really quite easy with the sample code provided.

Just copy the two source files "AJHBezierUtils.h" and"AJHBezierUtils.m" into your project, and import the .h file in your class that does the drawing.

Say you have an NSBezierPath named "path". After you have stroked your path, you can just make these calls:

NSBezierPath *arrow1, *arrow2;
arrow1 = [path bezierPathWithArrowHeadForStartOfLength:arrowSize angle:arrowAngle];
[arrow1 closePath];
[arrow1 fill];
[arrow1 stroke];

arrow2 = [path bezierPathWithArrowHeadForEndOfLength:arrowSize angle:arrowAngle];
[arrow2 closePath];
[arrow2 fill];
[arrow2 stroke];


and your arrows appear at the ends of your path, magically delicious! Btw, I'm using 15 for the arrowSize and 20 for the arrowAngle, but your milage may vary.



Rob Ross, Lead Software Engineer
E! Networks

---------------------------------------------------
"Beware of he who would deny you access to information, for in his heart he dreams himself your master." -- Commissioner Pravin Lal



On Jul 11, 2006, at 11:27 PM, Rob Ross wrote:

This is answered in the Cocoa-Dev FAQ:

http://www.alastairs-place.net/cocoa/faq.txt

I found this in the FAQ and it looks like it does the job:

http://www.alastairs-place.net/archives/000037.html


Rob Ross, Lead Software Engineer E! Networks

On Jul 11, 2006, at 7:53 PM, Eric Smith wrote:
Before I go pouring through sample code... is there a quick way to draw an arrow to a view? I have the mouse tracing out an NSBezierPath, and as the single click inserts joints into the line, I want an arrow to be drawn, bisecting each line segment. I'd like to avoid drawing each arrow using path segments, if possible.

Regards,
Eric
_______________________________________________
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


References: 
 >drawing arrows (From: Eric Smith <email@hidden>)
 >Re: drawing arrows (From: Rob Ross <email@hidden>)

  • Prev by Date: Re: How to perform a Coredata subquery
  • Next by Date: Re: Selector Not Recognized
  • Previous by thread: Re: drawing arrows
  • Next by thread: Re: [temporary workaround] NSDocument with NSMatrix crasher (10.4)
  • Index(es):
    • Date
    • Thread