Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!icdoc!qmc-cs!george From: george@cs.qmc.ac.uk (George Coulouris) Newsgroups: comp.sys.mac.hypercard Subject: Re: arrowheads at the end of lines. Message-ID: <1514@sequent.cs.qmc.ac.uk> Date: 7 Dec 89 00:10:58 GMT References: Reply-To: george@cs.qmc.ac.uk (George Coulouris) Organization: Computer Science Dept, Queen Mary and Westfield College, University of London, UK. Lines: 57 Summary: Expires: Sender: Followup-To: Distribution: Keywords: Funny you should ask that! I happen to have the answer. Actually, I did a MacApp example a few months ago that drew directed graphs, so I dug out the Pascal code, changed the :='s to 'put' and it ran (well almost, of course the Quickdraw procedures "MoveTo" and "Line" had to be defined in HyperTalk). Put the following script into a button to demonstrate it. After pressing the button, click anywhere on the card and an arrow will be drawn from 100,100 to the point you clicked at. on mouseUp set the hilite of me to true wait until the mouse is down arrow 100,100,the MouseH, the MouseV, 10, 1 set the hilite of me to false end mouseUp on arrow x1, y1, x2, y2, k, d -- k is the length of the arms of the arrow -- d is the fractional distance along the line at which arrow is placed put the tool into saveTool choose line tool MoveTo x1,y1 Line x2-x1,y2-y1 if x1 < x2 then put -1 into sign else put 1 into sign put atan((y1-y2)/(x1-x2)) into alpha -- the angle of the line put alpha+3.14/4 into beta -- plus 45 degrees put alpha-3.14/4 into gamma -- minus 45 degrees MoveTo trunc(x1+(x2-x1)*d), trunc(y1+(y2-y1)*d) line sign*trunc(k*cos(beta)), sign*trunc(k*sin(beta)) MoveTo trunc(x1+(x2-x1)*d), trunc(y1+(y2-y1)*d) line sign*trunc(k*cos(gamma)), sign*trunc(k*sin(gamma)) choose saveTool end arrow on MoveTo x, y global curpos put x&","&y into curpos end MoveTo on line x, y global curpos drag from curpos to (item 1 of curpos + x),(item 2 of curpos + y) end line -- | Computer Science Dept ARPA/Internet: george@cs.qmc.ac.uk | Queen Mary and Westfield College JANET: george@uk.ac.qmc.cs | Mile End Road | London E1 4NS England Office phone: +44 1 975 5201 (direct line) Home phone: +44 1 485 5896