Curves

Loading Ebi…
let route = Curve(keys=[
    Keyframe(time=0s, value=-138pt, interpolation="linear"),
    Keyframe(time=1s, value=0pt),
    Keyframe(time=2s, value=138pt),
    Keyframe(time=3s, value=-138pt)
])
mut position_x = -138pt
let track = <Box w-300 h-4 rounded-full bg-dark3 x_align={Align.Center} y_align={Align.Center}/>
let marker = <Box w-34 h-34 rounded-full fill="green3" position={[position_x,0pt]} x_align={Align.Center} y_align={Align.Center}/>
track
marker
animate(position_x, curve=route)

Change the first key's interpolation to "hold". The dot stays at its first position until the next key. "linear" moves at a steady rate, while "bezier" eases through the keys.

Keyframed values

A Curve<T> maps time to a numeric scalar or fixed-size numeric List.

curve.sample(time: Duration): T
curve.at(progress: Number): T
curve.duration(): Duration

sample uses an exact timestamp; at uses normalized progress 0..1. Values outside the key interval hold the nearest endpoint. Negative times fail.

animate takes either to= with a duration or curve=. With a curve, duration defaults to its last timestamp; an explicit duration retimes it. ease cannot be combined with curve.

Keyframe arguments

Keyframe(time: Duration, value: T, ...) returns a record used in Curve(keys=[...]). All keys must have matching units and List lengths.

ArgumentType / defaultMeaning
timeDuration; requiredTimestamp; first key is zero, subsequent times strictly increase.
valueNumeric scalar or fixed-size numeric List; requiredValue at the key.
interpolation"bezier" (default), "linear", "hold"How this key connects to the next.
tangents"auto_clamped" (default), "auto", "manual"Automatic handles with/without overshoot limiting, or manual handles.
handle_in / handle_outOptional {time: Duration, value: T}Offsets from this key; incoming time is nonpositive, outgoing nonnegative.

Reflect the key List to edit it in Shrimply. Curves allow 2–4096 keys, up to 256 channels and 65,536 key/channel components; finite duration is at most two hours. Handles must stay ordered within each segment.

Geometric paths

Curve(points=[[0,0], [10,20], [30,20]]) defines a path without a clock. at(progress) samples distance along it; direction(progress) returns its tangent. Animate a scalar progress value to control travel speed. Timed sample, duration and animate(curve=...) require keyframes.

Pass a 2D path as the target of move_to. Its first and last points set the element's start and end positions. Use two pt coordinates or two percentages at each point, with the same units throughout.

let arc = Curve(points=[[-120pt, 80pt], [0pt, -75pt], [120pt, 80pt]])
marker.move_to(arc, duration=800ms)

Geometric paths use linear timing by default and accept ease=. Keyframed paths use their timestamps and easing handles. Set duration= to retime them.