From 95bf6b95a9d47a16219a26e19004d22c52180587 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Mon, 22 Feb 2016 20:15:08 +0100 Subject: 2016-02-22 19:57:00 --- metapost/context/base/mpiv/mp-tool.mpiv | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'metapost') diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index eea2e12a3..64500a056 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -1096,20 +1096,42 @@ enddef ; %D Arrow. +newinternal ahvariant ; ahvariant := 0 ; +newinternal ahdimple ; ahdimple := 1/5 ; + +vardef arrowhead expr p = + save q, e, r ; + pair e ; e = point length p of p ; + path q ; q = gobble(p shifted -e cutafter makepath(pencircle scaled (2ahlength))) cuttings ; + if ahvariant > 0: + path r ; r = gobble(p shifted -e cutafter makepath(pencircle scaled ((1-ahdimple)*2ahlength))) cuttings ; + fi + (q rotated (ahangle/2) & reverse q rotated -(ahangle/2) + if ahvariant = 1: + -- point 0 of r -- + elseif ahvariant = 2 : + ... point 0 of r ... + else : + -- + fi + cycle + ) shifted e +enddef ; + vardef drawarrowpath expr p = save autoarrows ; boolean autoarrows ; autoarrows := true ; drawarrow p _pth_opt_ enddef ; def midarrowhead expr p = - arrowhead p cutafter (point length(p cutafter point .5 along p)+ahlength on p) + arrowhead p cutafter (point length(p cutafter point .5 along p) + ahlength on p) enddef ; vardef arrowheadonpath (expr p, s) = save autoarrows ; boolean autoarrows ; autoarrows := true ; set_ahlength(scaled ahfactor) ; % added - arrowhead p if s<1 : cutafter (point (s*arclength(p)+.5ahlength) on p) fi + arrowhead p if s < 1 : cutafter (point (s*arclength(p) + (ahlength/2)) on p) fi enddef ; %D Points. -- cgit v1.2.3