Last active
May 31, 2020 08:06
-
-
Save Zeta611/6d9b676e636d75f1dfa7bef433e6b9fc to your computer and use it in GitHub Desktop.
[drawShifted] Shift a path by an absolute value in Asymptote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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