Skip to content

Instantly share code, notes, and snippets.

@Zeta611
Last active May 31, 2020 08:06
Show Gist options
  • Save Zeta611/6d9b676e636d75f1dfa7bef433e6b9fc to your computer and use it in GitHub Desktop.
Save Zeta611/6d9b676e636d75f1dfa7bef433e6b9fc to your computer and use it in GitHub Desktop.
[drawShifted] Shift a path by an absolute value in Asymptote
void drawShifted(
path g,
pair trueshift,
picture pic=currentpicture,
Label label="",
pen pen=currentpen,
arrowbar arrow=None,
arrowbar bar=None,
margin margin=NoMargin,
marker marker=nomarker
) {
pic.add(new void(frame f, transform t) {
picture opic;
draw(
opic,
L=label,
shift(trueshift) * t * g,
p=pen,
arrow=arrow,
bar=bar,
margin=margin,
marker=marker
);
add(f, opic.fit());
});
pic.addBox(min(g), max(g), trueshift + min(pen), trueshift + max(pen));
}
// Examples
// drawshifted((x,barheight) -- (x+dx, barheight), trueshift=barshifty, label=dxlabel, bar=Bars);
// drawshifted((barx,0) -- (barx, f(x)), trueshift=barshiftx, label=fxlabel, arrow=Arrows(), bar=Bars);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment