Guide · 4 of 8

Lines and curves

On this page

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.

A slide titled “Where the clap goes”: an arrow labelled sound runs from a box, Clap, up to a box, Wall; an arrow with an open head labelled echo runs from Wall down to Listener; and a line labelled absorbed leaves the bottom of Clap, turns at a right angle and ends in a dot at a shaded box, Curtain.
[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.

A slide titled “Two ways to the listener”: between a box, Clap, on the left and a box, Listener, on the right stands a shaded box, Pillar; a line with a sharp head labelled reflected goes up and over the pillar in straight pieces, and a smooth curved arrow labelled around bends below it.
[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.

A slide titled “Driving the qubit”: a sine wave with eight cycles grows from zero and falls back to zero under a dashed raised-cosine envelope drawn above and below it, with an arrowhead at its right end, and the caption “A sine under a raised-cosine envelope, dashed.”
===
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.
]