Guide · 4 of 8
Lines and curves
Join elements with lines, draw a path through points, or plot a formula.
Join two elements
[line from=#a to=#b arrow=end:] joins the sides of #a and #b that face each other and follows them wherever they are drawn. from-side and to-side choose a side, and route=elbow turns at right angles. A class picks the head, as .open-head or .dot-head.
[title: Where the clap goes]
[subtitle: Sound, echo and what the curtain takes]
[box #clap .card x=6% y=48% w=20%:
Clap
]
[box #wall .card x=40% y=32% w=20%:
Wall
]
[box #ear .card x=74% y=48% w=20%:
Listener
]
[box #curtain .tint x=40% y=74% w=20%:
Curtain
]
[line .stealth-head from=#clap to=#wall arrow=end style="--head-size: lg":]
[box x=28% y=36% w=12% style="text-align: center":
sound
]
[line .open-head from=#wall to=#ear arrow=end:]
[box x=61% y=36% w=12% style="text-align: center":
echo
]
[line .dot-head from=#clap from-side=bottom to=#curtain to-side=left route=elbow arrow=end:]
[box x=20% y=72% w=16% style="text-align: center":
absorbed
]Go through points
points=((430, 500), (760, 300), (1160, 300)) lists the points a line goes through, each (x, y) in logical pixels; the first and last are its ends. It goes straight from one to the next, or, with the class .smooth, along one smooth curve through them all.
[title: Two ways to the listener]
[subtitle: Reflected over the pillar, or around it]
[box #clap .card x=5% y=44% w=16%:
Clap
]
[box #pillar .tint x=44% y=40% w=12% h=22%:
Pillar
]
[box #ear .card x=79% y=44% w=16%:
Listener
]
[line .stealth-head points=((430, 500), (760, 300), (1160, 300), (1490, 500)) arrow=end:]
[box x=42% y=21% w=16% style="text-align: center":
reflected
]
[line .smooth points=((430, 590), (700, 800), (1220, 800), (1490, 590)) arrow=end:]
[box x=42% y=75% w=16% style="text-align: center":
around
]Plot a formula
[curve f="x -> sin(x)" domain=(-pi, pi):] draws a formula over the horizontal range from −π to π, inside the box its x, y, w and h give. Vertically, −1 is at the bottom of the box and 1 at the top unless range= says otherwise. Formulas used often can be named under functions: in the document settings.
===
functions:
rc(t): 0.5*(1-cos(2*pi*t))
drive(t): rc(t)*sin(2*pi*8*t)
===
[title: Driving the qubit]
[subtitle: A raised-cosine pulse, eight cycles]
[curve .muted x=8% y=28% w=84% h=44% f="rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .muted x=8% y=28% w=84% h=44% f="-rc(t)" style="stroke-dasharray: 12px 8px":]
[curve .primary x=8% y=28% w=84% h=44% f="drive(t)" arrow=end:]
[box x=8% y=78% w=84%:
A sine under a raised-cosine envelope, $\tfrac{1}{2}(1-\cos 2\pi t)$, dashed.
]