From 1873d112b56f49e40ece29916ede51933412bca8 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 31 Jul 2019 18:26:52 +0200 Subject: 2019-07-31 18:13:00 --- tex/context/base/mkiv/meta-imp-dum.mkiv | 127 ++++++++++++++++---------------- 1 file changed, 64 insertions(+), 63 deletions(-) (limited to 'tex/context/base/mkiv/meta-imp-dum.mkiv') diff --git a/tex/context/base/mkiv/meta-imp-dum.mkiv b/tex/context/base/mkiv/meta-imp-dum.mkiv index b84d4ac7a..457de4b35 100644 --- a/tex/context/base/mkiv/meta-imp-dum.mkiv +++ b/tex/context/base/mkiv/meta-imp-dum.mkiv @@ -30,69 +30,70 @@ %D %D \typebuffer \getbuffer -% currently preparempvariables is unable to resolve number -% fractions like reduction - -% June 22, 2003, this definition was patched to adapt itself -% to transparent colors, but ... in 2011 we no longer have -% is_transparent so we revert. -% -% \startuseMPgraphic{placeholder}{width,height,reduction,color} -% numeric w, h, d, r ; color c, b, cc ; path p ; boolean t ; -% t := is_transparent(\MPvar{color}) ; -% c := not_transparent(\MPvar{color}) ; -% b := not_transparent(white) ; -% w := \MPvar{width} ; -% h := \MPvar{height} ; -% r := \MPvar{reduction} ; -% d := max(w,h) ; -% p := unitsquare xyscaled (w,h) ; -% cc := r[.5c,b] ; -% fill p withcolor if t : transparent(1,.5,cc) else : cc fi ; -% for i := 1 upto 60 : -% cc := r[c randomized(.3,.9),b] ; -% fill fullcircle -% scaled (d/5 randomized (d/5)) -% shifted (center p randomized (d)) -% withcolor if t : transparent(1,.5,cc) else : cc fi ; -% endfor ; -% clip currentpicture to p ; -% \stopuseMPgraphic - -\startuseMPgraphic{minifun::figure:placeholder}{width,height,reduction,color} - begingroup ; - save w, h, d, r, p, c, b ; - numeric w, h, d, r ; path p ; - if cmykcolor \MPvar{color} : - cmykcolor c, b ; b := (0,0,0,0) - else : - color c, b ; b := (1,1,1) - fi ; - c := \MPvar{color} ; - w := \MPvar{width} ; - h := \MPvar{height} ; - r := \MPvar{reduction} ; - d := max(w,h) ; - p := unitsquare xyscaled (w,h) ; - fill p withcolor r[.5c,b] ; - for i := 1 upto 60 : - fill fullcircle - scaled (d/5 randomized (d/5)) - shifted (center p randomized (d)) - withcolor r[c randomized(.3,.9),b] ; - endfor ; - clip currentpicture to p ; - endgroup ; -\stopuseMPgraphic - -\defineoverlay - [figure:placeholder:graphic] - [\useMPgraphic - {minifun::figure:placeholder}% - {width=\figurewidth,% - height=\figureheight,% - reduction=\externalfigureparameter\c!reduction,% - color=placeholder:\the\c_grph_replacement_n}] % weird, why do we need to prefix the palette +\startmkivmode + +%D Currently preparempvariables is unable to resolve number fractions like +%D reduction. + + \startuseMPgraphic{minifun::figure:placeholder}{width,height,reduction,color} + begingroup ; + save w, h, d, r, p, c, b ; + numeric w, h, d, r ; path p ; + if cmykcolor \MPvar{color} : + cmykcolor c, b ; b := (0,0,0,0) + else : + color c, b ; b := (1,1,1) + fi ; + c := \MPvar{color} ; + w := \MPvar{width} ; + h := \MPvar{height} ; + r := \MPvar{reduction} ; + d := max(w,h) ; + p := unitsquare xyscaled (w,h) ; + fill p withcolor r[.5c,b] ; + for i := 1 upto 60 : + fill fullcircle + scaled (d/5 randomized (d/5)) + shifted (center p randomized (d)) + withcolor r[c randomized(.3,.9),b] ; + endfor ; + clip currentpicture to p ; + endgroup ; + \stopuseMPgraphic + + \defineoverlay + [figure:placeholder:graphic] + [\useMPgraphic + {minifun::figure:placeholder}% + {width=\figurewidth,% + height=\figureheight,% + reduction=\externalfigureparameter\c!reduction,% + color=placeholder:\the\c_grph_replacement_n}] % weird, why do we need to prefix the palette + +\stopmkivmode + +\startlmtxmode + + \defineMPparameterset + [placeholder] + [width=dimension, + height=dimension, + reduction=number, + color=string, + alternative=string] + + \defineoverlay + [figure:placeholder:graphic] + [{\useMPmacro + [minifun]% + [placeholder]% + [width=\figurewidth,% + height=\figureheight,% + alternative=\externalfigureparameter\c!alternative, + reduction=\externalfigureparameter\c!reduction,% + color=placeholder:\the\c_grph_replacement_n]}] + +\stoplmtxmode \definepalet [placeholder] -- cgit v1.2.3