On Thu, 13 May 2021, Henning Hraban Ramm wrote: > > > Am 11.05.2021 um 18:02 schrieb Aditya Mahajan : > > > > Look at this old code on how hide such code behind a macro to have a clean interface: > > > > https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp > > Hi Aditya, > I’m trying to include my additions into your code, but it doesn’t work. > > > numeric sketch_amount; sketch_amount := 3bp; > numeric sketch_passes; sketch_passes := 5; > > def sketchdraw expr p = > do_sketchdraw(p if (path p): randomized sketch_amount fi) > enddef; > > def do_sketchdraw(expr p) text t = > normaldraw p t ; > enddef; > > > Now I want to draw that path several times. > > If I understand it right, I can’t put that into "sketchdraw" because that leaves the end open for path additions like "withcolor". > > But it also doesn’t work in "do_sketchdraw"; I thought it might like this: A slightly different approach is needed. See attached. I also added a bit a error protection in case someone sets sketch_passes to be negative by mistake. It may be interesting to rewrite these macros using the new key-value interface for metapost, so that something like this works: \sketchdraw[amount=3bp, passes=5, transparency=yes] fullsquare scaled 1cm withcolor red;