unit arrowLines; { Copyright © 1990, by M. Gibbs, all rights reserved. } { Adapted from MacTutor Magazine, October, 1985. Article by } { Alan Wootton, who used an algorithm by Rick Flott. } { This unit provides routines for drawing lines with arrow heads.} { All the procedures herein use normal QuickDraw calls, and draw } { in the active grafport. QuickDraw pen characteristics, color } { settings, etc., will all affect the lines in the usual way. } { All coordinates are local to the active grafport. } { NOTE: procedure setArrowType MUST be called at least once } { prior to using any of the arrow line drawing } { procedures. It may be called subsequently at any time } { to change the line drawing parameters. } interface procedure setArrowType (arrowSize, arrowLength: integer); { Sets the size and length of the arrow heads for subsequent } { lines. } procedure arrowLineTo (h, v: integer); { Draws a line from the current pen location to the specified } { position with an arrow head as specified in the most recent } { call to setArrowType. } procedure arrowLine (h, v: integer); { Draws a line from the current pen location to a point h pixels } { horizontally and v pixels vertically from the pen, with an } { arrow head as specified in the most recent call to } { setArrowType. } implementation var aSize, aH, aL: integer; procedure setArrowType (arrowSize, arrowLength: integer); begin aSize := arrowSize; aH := aSize div 2; aL := arrowLength; end; procedure arrowLineTo (h, v: integer); var startPt: point; r: rect; ang: integer; begin setRect(r, h - aL, v - aL, h + aL, v + aL); getPen(startPt); PtToAngle(r, startPt, ang); lineto(h, v); paintArc(r, ang - aH, aSize); end; procedure arrowLine (h, v: integer); var startPt: point; r: rect; ang: integer; begin getPen(startPt); setRect(r, startPt.h + h - aL, startPt.v + v - aL, startPt.h + h + aL, startPt.v + v + aL); PtToAngle(r, startPt, ang); line(h, v); paintArc(r, ang - aH, aSize); end; end.