%%Title: arrows.pslib % Usage: % Straight Arrow % x_from y_from x_to y_to stemthick headthick headlength arrow fill/stroke % % Arc Arrow: % Unidirectional % cx cy radius from_angle to_angle stemthick headthick headlength arcarrow fill/stroke % % Bidirectional % cx cy radius from_angle to_angle stemthick headthick headlength arcarrow fill/stroke % % p0 p1 p2 p3 9 24 30 curvearrow (no fill/stroke!) % (p0, p1, p2, p3: x,y pairs) % /arrowdict 1 dict def arrowdict begin /mtrx matrix def end /arrow { arrowdict begin /headlength exch def /halfheadthickness exch 2 div def /halfthickness exch 2 div def /tipy exch def /tipx exch def /taily exch def /tailx exch def /dx tipx tailx sub def /dy tipy taily sub def /arrowlength dx dx mul dy dy mul add sqrt def /angle dy dx atan def /base arrowlength headlength sub def /savematrix mtrx currentmatrix def tailx taily translate angle rotate 0 halfthickness neg moveto base halfthickness neg lineto base halfheadthickness neg lineto arrowlength 0 lineto base halfheadthickness lineto base halfthickness lineto 0 halfthickness lineto closepath savematrix setmatrix end } def /arcarrowdict 1 dict def /arcarrow{ arcarrowdict begin /headlength exch def /headthickness exch def /stemthickness exch def /a2 exch def /a1 exch def /rad exch def /cy exch def /cx exch def /x1 {a1 cos rad mul} def /y1 {a1 sin rad mul} def /x2 {a2 cos rad mul} def /y2 {a2 sin rad mul} def /rado {rad stemthickness 2 div add}def /radi {rad stemthickness 2 div sub}def /radho {rad headthickness 2 div add}def /radhi {rad headthickness 2 div sub}def /headangle {headlength rad atan} def a2 a1 gt {/am {a2 headangle sub}def} {/am {a2 headangle add}def} ifelse /xmo {am cos radho mul} def /ymo {am sin radho mul} def /xmi {am cos radhi mul} def /ymi {am sin radhi mul} def newpath a2 a1 gt {% a1 < a2 cx cy rado a1 am arc cx xmo add cy ymo add lineto cx x2 add cy y2 add lineto cx xmi add cy ymi add lineto cx cy radi am a1 arcn closepath } {% a1 > a2 cx cy rado a1 am arcn cx xmo add cy ymo add lineto cx x2 add cy y2 add lineto cx xmi add cy ymi add lineto cx cy radi am a1 arc closepath } ifelse end }def /arrowbdict 1 dict def arrowbdict begin /mtrx matrix def end /arrowb { arrowbdict begin /headlength exch def /halfheadthickness exch 2 div def /halfthickness exch 2 div def /tipy exch def /tipx exch def /taily exch def /tailx exch def /dx tipx tailx sub def /dy tipy taily sub def /arrowlength dx dx mul dy dy mul add sqrt def /angle dy dx atan def /base arrowlength headlength sub def /savematrix mtrx currentmatrix def tailx taily translate angle rotate 0 0 moveto headlength halfheadthickness neg lineto headlength halfthickness neg lineto base halfthickness neg lineto base halfheadthickness neg lineto arrowlength 0 lineto base halfheadthickness lineto base halfthickness lineto headlength halfthickness lineto headlength halfheadthickness lineto closepath savematrix setmatrix end } def /arcarrowbdict 1 dict def /arcarrowb{ arcarrowbdict begin /headlength exch def /headthickness exch def /stemthickness exch def /a2 exch def /a1 exch def /rad exch def /cy exch def /cx exch def /x1 {a1 cos rad mul} def /y1 {a1 sin rad mul} def /x2 {a2 cos rad mul} def /y2 {a2 sin rad mul} def /rado {rad stemthickness 2 div add}def /radi {rad stemthickness 2 div sub}def /radho {rad headthickness 2 div add}def /radhi {rad headthickness 2 div sub}def /headangle {headlength rad atan} def a2 a1 gt { /am2 {a2 headangle sub}def /am1 {a1 headangle add}def }{ /am2 {a2 headangle add}def /am1 {a1 headangle sub}def } ifelse /xm2o {am2 cos radho mul} def /ym2o {am2 sin radho mul} def /xm2i {am2 cos radhi mul} def /ym2i {am2 sin radhi mul} def /xm1o {am1 cos radho mul} def /ym1o {am1 sin radho mul} def /xm1i {am1 cos radhi mul} def /ym1i {am1 sin radhi mul} def newpath a2 a1 gt {% a1 < a2 cx cy rado am1 am2 arc cx xm2o add cy ym2o add lineto cx x2 add cy y2 add lineto cx xm2i add cy ym2i add lineto cx cy radi am2 am1 arcn cx xm1i add cy ym1i add lineto cx x1 add cy y1 add lineto cx xm1o add cy ym1o add lineto closepath } {% a1 > a2 cx cy rado am1 am2 arcn cx xm2o add cy ym2o add lineto cx x2 add cy y2 add lineto cx xm2i add cy ym2i add lineto cx cy radi am2 am1 arc cx xm1i add cy ym1i add lineto cx x1 add cy y1 add lineto cx xm1o add cy ym1o add lineto closepath } ifelse end }def /curvearrowdict 1 dict def /curvearrow { curvearrowdict begin currentlinewidth /lw exch def /headlength exch def /headthickness exch 2 div def /stemthickness exch def /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def /y0 exch def /x0 exch def /len {x1 x0 sub dup mul y1 y0 sub dup mul add sqrt}def /llen {len 0.25 add}def /xm { len headlength sub x3 mul headlength x2 mul add len div }def /ym { len headlength sub y3 mul headlength y2 mul add len div }def /xms { llen headlength sub x3 mul headlength x2 mul add llen div }def /yms { llen headlength sub y3 mul headlength y2 mul add llen div }def stemthickness setlinewidth xms yms moveto x2 y2 x1 y1 x0 y0 curveto stroke /dx {x3 xm sub}def /dy {y3 ym sub}def /theta {dy dx atan} def /px {theta 90 add cos headthickness mul }def /py {theta 90 add sin headthickness mul }def x3 y3 moveto xm px add ym py add lineto xm px sub ym py sub lineto closepath fill lw setlinewidth end }def /curvearrowbdict 1 dict def /curvearrowb { curvearrowbdict begin currentlinewidth /lw exch def /headlength exch def /headthickness exch 2 div def /stemthickness exch def /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def /y0 exch def /x0 exch def /len1 {x1 x0 sub dup mul y1 y0 sub dup mul add sqrt}def /len2 {x2 x3 sub dup mul y2 y3 sub dup mul add sqrt}def /llen1 {len1 0.9 add}def /llen2 {len2 0.9 add}def /xm1 { len1 headlength sub x3 mul headlength x2 mul add len1 div }def /ym1 { len1 headlength sub y3 mul headlength y2 mul add len1 div }def /xm2 { len2 headlength sub x0 mul headlength x1 mul add len2 div }def /ym2 { len2 headlength sub y0 mul headlength y1 mul add len2 div }def /xms1 { llen1 headlength sub x3 mul headlength x2 mul add llen1 div }def /yms1 { llen1 headlength sub y3 mul headlength y2 mul add llen1 div }def /xms2 { llen2 headlength sub x0 mul headlength x1 mul add llen2 div }def /yms2 { llen2 headlength sub y0 mul headlength y1 mul add llen2 div }def stemthickness setlinewidth xms1 yms1 moveto x2 y2 x1 y1 xms2 yms2 curveto stroke /dx {x0 xm2 sub}def /dy {y0 ym2 sub}def /theta {dy dx atan} def /px {theta 90 add cos headthickness mul }def /py {theta 90 add sin headthickness mul }def x0 y0 moveto xm2 px add ym2 py add lineto xm2 px sub ym2 py sub lineto closepath fill /dx {x3 xm1 sub}def /dy {y3 ym1 sub}def /theta {dy dx atan} def /px {theta 90 add cos headthickness mul }def /py {theta 90 add sin headthickness mul }def x3 y3 moveto xm1 px add ym1 py add lineto xm1 px sub ym1 py sub lineto closepath fill lw setlinewidth end }def