I've read through most of the Metafun manual, but I can't seem to find any mention of a relative positioning system. I have two use cases in mind. First, I would like to position points along a path in relation to previous points similar to the
++ notation in tikz. Second, I would like to position complex shapes a certain distance away from each other.
I don't know how to approach the first case with Metafun, but here is a working example (in ConTeXt) for a line drawn by successive additive increments in tikz:
%&context \usemodule[tikz] \starttext \starttikzpicture \path[draw, black] (0cm, 0cm) -- ++(1cm, 0cm) -- ++(0cm, 1cm); \stoptikzpicture % vs. absolute positioning in Metafun \startMPcode draw (0cm, 0cm) -- (1cm, 0cm) -- (1cm, 1cm); \stopMPcode \stoptext
The second case could be tackled with
xshifted for the simplest cases, but it becomes necessary to make multiple edits if the dimensions of a path/picture change.
%&context \starttext \startMPcode path P; % Works with one set of sizes P = fullcircle; draw P scaled 1cm; draw P scaled 1cm xshifted 2cm; \stopMPcode \startMPcode path P; % xshift distance must be manually adapted with size changes P = fullcircle; draw P scaled 2cm; draw P scaled 1cm xshifted 1cm; \stopMPcode \stoptext
I found relative positioning examples in commands like
label.rt and I'm aware of the boxes package, but I am looking for a more general approach if it exists -- like setting the distance between arbitrary points along a path rather than defining bounding boxes.