From 82ea6961d63e1ed2924e5ac885a03a4cf65a2069 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Tue, 14 Jul 2015 11:15:05 +0200 Subject: 2015-07-14 10:39:00 --- metapost/context/base/mp-mlib.mpiv | 42 ++++++++++++++++++++++++++++++++++---- metapost/context/base/mp-tool.mpiv | 28 ++++++++++++++++++++----- 2 files changed, 61 insertions(+), 9 deletions(-) (limited to 'metapost') diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index decdda15b..96c984e37 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -346,7 +346,7 @@ vardef plain_thelabel@#(expr p,z) = enddef; def plain_label = % takes two arguments, contrary to textext that takes one - draw plain_thelabel + normaldraw plain_thelabel enddef ; let mfun_label = label ; @@ -362,6 +362,12 @@ def usemetafunlabels = let thelabel = mfun_thelabel ; enddef ; +vardef dotlabel@#(expr s,z) text t_ = + label@#(s,z) t_ ; + interim linecap := rounded ; + normaldraw z withpen pencircle scaled dotlabeldiam t_ ; +enddef ; + plain_compatibility_data := plain_compatibility_data & "save label, thelabel ;" & "useplainlabels ;" ; % next comes own own: @@ -394,7 +400,7 @@ vardef thelabel@#(expr p,z) = enddef; def label = % takes two arguments, contrary to textext that takes one - draw thelabel + normaldraw thelabel enddef ; vardef anchored@#(expr p, z) = % beware: no "+ mfun_laboff@#" here (never!) @@ -907,10 +913,10 @@ def mfun_do_outline_options_r = enddef ; vardef outlinetext@# (expr t) text rest = save kind ; string kind ; kind := str @# ; currentoutlinetext := currentoutlinetext + 1 ; - image ( draw image ( + image ( normaldraw image ( if mfun_trial_run : % lua.mp.report("set outline text",currentoutlinetext); - draw unitsquare + normaldraw unitsquare withprescript "ot_stage=trial" withprescript "ot_index=" & decimal currentoutlinetext withprescript "ot_kind=" & kind @@ -935,6 +941,34 @@ vardef outlinetext@# (expr t) text rest = ) mfun_do_outline_options_r ; ) enddef ; +% A few helpers: + +numeric mfun_c_b_llx, mfun_c_b_h, mfun_c_b_w, mfun_c_b_l ; + +vardef checkedbounds(expr llx,lly,urx,ury) = + mfun_c_b_llx := min(xpart llcorner currentpicture,llx) ; + mfun_c_b_urx := max(xpart urcorner currentpicture,urx) ; + mfun_c_b_lly := min(ypart llcorner currentpicture,lly) ; + mfun_c_b_ury := max(ypart urcorner currentpicture,ury) ; + (mfun_c_b_llx,mfun_c_b_lly) -- + (mfun_c_b_urx,mfun_c_b_lly) -- + (mfun_c_b_urx,mfun_c_b_ury) -- + (mfun_c_b_llx,mfun_c_b_ury) -- cycle +enddef ; + +vardef checkbounds(expr llx,lly,urx,ury) = + setbounds currentpicture to checkedbounds(llx,lly,urx,ury) ; +enddef ; + +vardef strut(expr ht,dp) = + setbounds currentpicture to checkedbounds(0,0,ht,dp) ; +enddef ; + +vardef rule(expr wd,ht,dp) = + image (fill (0,-dp)--(wd,-dp)--(wd,ht)--(0,ht)--cycle) +enddef ; + + % Housekeeping extra_beginfig := extra_beginfig & "currentgraphictext := 0 ; " ; diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv index 341a0a41a..13104f17e 100644 --- a/metapost/context/base/mp-tool.mpiv +++ b/metapost/context/base/mp-tool.mpiv @@ -1077,13 +1077,13 @@ def drawpathoptions (text t) = def _pth_opt_ = t enddef ; enddef ; numeric drawoptionsfactor ; drawoptionsfactor := pt ; def resetdrawoptions = - drawlineoptions (withpen pencircle scaled 1drawoptionsfactor withcolor .5white) ; - drawpointoptions (withpen pencircle scaled 4drawoptionsfactor withcolor black) ; - drawcontroloptions(withpen pencircle scaled 2.5drawoptionsfactor withcolor black) ; + drawlineoptions (withpen pencircle scaled 1.0 drawoptionsfactor withcolor .5white) ; + drawpointoptions (withpen pencircle scaled 4.0 drawoptionsfactor withcolor black) ; + drawcontroloptions(withpen pencircle scaled 2.5 drawoptionsfactor withcolor black) ; drawlabeloptions () ; - draworiginoptions (withpen pencircle scaled 1drawoptionsfactor withcolor .5white) ; + draworiginoptions (withpen pencircle scaled 1.0 drawoptionsfactor withcolor .5white) ; drawboundoptions (dashed evenly _ori_opt_) ; - drawpathoptions (withpen pencircle scaled 5drawoptionsfactor withcolor .8white) ; + drawpathoptions (withpen pencircle scaled 5.0 drawoptionsfactor withcolor .8white) ; enddef ; resetdrawoptions ; @@ -1285,11 +1285,29 @@ def do_visualizedfill text t = drawpointlabels _c_ ; enddef ; +def detaileddraw expr c = + if picture c : normaldraw c else : path _c_ ; _c_ := c ; do_detaileddraw fi +enddef ; + +def do_detaileddraw text t = + drawpath _c_ t ; + drawcontrollines _c_ ; + drawcontrolpoints _c_ ; + drawpoints _c_ ; + % % for labels we need an third run (as the second will mark the numbers); i could preroll them + % % but then the hash needs to handle that as well (as now we keep numbering) + % drawpointlabels _c_ ; +enddef ; + def visualizepaths = let fill = visualizedfill ; let draw = visualizeddraw ; enddef ; +def detailpaths = + let draw = detaileddraw ; +enddef ; + def naturalizepaths = let fill = normalfill ; let draw = normaldraw ; -- cgit v1.2.3