curve

An expression in x plotted as a curve. expression is the implicit attribute; domain and range clip where it draws. Publishes derived max and min over the plotted domain.

curveNode
Only withxyargandpolarplane
A blue parabola and a teal sine wave crossing it.A blue parabola and a teal sine wave crossing it.

A curve plots an expression in x: curve(expression: x^2; colour: blue) — in theta on the polar plane, where it is r(θ). Expressions may reference parameters — a * sin(b * x) bends live as the reader drags a and b — and domain / range clip where it draws. A curve exposes derived max and min over its plotted domain.

A function defined in pieces is written with min(a, b), max(a, b) and clamp(x, lo, hi) rather than as several curves with clipped domains, and it stays one curve under a parameter: a response that saturates is min(2x, 10), and Huber's ρ — quadratic in the middle, linear in the tails — is the clamped distance clamp(abs(x), 0, c)^2/2 + c * (abs(x) - clamp(abs(x), 0, c)). (Not min(x^2/2, c * abs(x) - c^2/2): the two differ by (abs(x) - c)^2/2, which is never negative, so that min is the linear branch everywhere.)

Or a curve is a position in t: curve(x: cos(t); y: sin(t); t: [0, 2pi]) on the ordinary plane, z(t) on the argand one, r and theta in t on the polar one — with the interval t runs over, and no expression. A parametric curve takes fill, since its path can enclose something: a closed loop fills itself, and an arc closes across its own chord — close names a point to come back through first, so an arc closed through the centre of its circle is the sector. A y(x) curve is refused both: the region under a function is an integral, and saying so keeps one idea in one place.


#Attributes

On any plane
tAnimatable
The interval the parametric variable runs over — [0, 2pi], ends parametised. Required with the parametric coordinates; not with expression.
colourAnimatable
Curve colour.
bluelight-bluedark-blueredlight-reddark-redorangelight-orangedark-orangeyellowlight-yellowdark-yellowteallight-tealdark-tealgreenlight-greendark-greenpinklight-pinkdark-pinkpurplelight-purpledark-purplegreylight-greydark-greyneutralhex(…)rgb(…)
Also written: color
Defaultblue
widthAnimatable
Stroke width.
Default2
dashedAnimatable
Dashed stroke.
Defaultfalse
fillAnimatable
Shades the region the path encloses — the PARAMETRIC form only, where a path can enclose one: an ellipse, a cardioid, a lissajous loop. An arc closes straight across, which shades the segment of a circle; close turns that into the sector. A y(x) curve takes integral instead, which shades the area under a function and reports what it is worth.
Also written: filled
Defaultfalse
closeAnimatable
A point the shaded region comes back through before it closes, as a coordinate pair. An arc closed through the centre of its circle is a sector — the wedge no other mark can draw, since polygon has straight sides and integral closes to the axis. Nothing without fill.
Also written: close-at
domainAnimatable
Restrict domain.
Also written: x-domain
rangeAnimatable
Restrict range.
Also written: y-range
endpointsAnimatable
Endpoint decoration: an arrow where the curve runs on past the frame, and a dot where its domain stops it — filled for a closed end, open for an open one. Holes in the function are marked either way.
Also written: arrowheads, arrow, arrowhead, arrows
Defaulttrue
label
Text drawn beside the element — rich text, so $maths$ and inline formatting render. Fades and draws with the element.
hiddenAnimatable
Declared but not drawn. Animatable — hidden: true !cue.to{false}(at: 2) reveals it — and unlike a cue, a hidden element still frames the plot, so the axes do not jump when it appears.
Defaultfalse
lock
Keeps the reader from editing this element on an editable: graph. Nothing at all on a graph that is not editable.
Also written: locked
Defaultfalse
text-sizeAnimatable
Text size.
Default20
layerAnimatable
Paint order among the marks: a higher layer is drawn later, on top; equal or omitted, the marks stack in document order (later on top). Written z: before the argand plane took that letter for its coordinate.
Only withxyplane
expressionImplicitAnimatable
The curve as a function of the plane's independent axis: y(x) on the ordinary plane, r(theta) on the polar one. Refused on the argand plane, which has no independent axis — write a position in t there. Not with the parametric coordinates.
Also written: exp, f, func, functionCan be written as shorthand: curve:value
xAnimatable
A position in t: the x coordinate as an expression in t, with y: and t: — curve(x: cos(t); y: sin(t); t: [0, 2pi]). On the ordinary plane; not with expression.
yAnimatable
A position in t: the y coordinate as an expression in t, with x: and t:.
Only withargandplane
zAnimatable
On the argand plane, the curve as z(t): a complex expression in t — curve(z: sqrt(13) * e^(i * t); t: [0, 2pi]) — with t:.
Only withpolarplane
expressionImplicitAnimatable
The curve as a function of the plane's independent axis: y(x) on the ordinary plane, r(theta) on the polar one. Refused on the argand plane, which has no independent axis — write a position in t there. Not with the parametric coordinates.
Also written: exp, f, func, functionCan be written as shorthand: curve:value
rAnimatable
On the polar plane, a position in t: the distance as an expression in t, with theta: and t:.
thetaAnimatable
On the polar plane, a position in t: the angle as an expression in t, with r: and t:.

#Derived attributes

Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.

maxDerived
The largest value the expression takes over the curve's effective domain, tracking parameters live.
minDerived
The smallest value the expression takes over the curve's effective domain, tracking parameters live.

#Allowed in

#Examples

A blue parabola.A blue parabola.
canvas.graph{
    curve(expression: x^2; colour: blue)
}
One period of a sine wave, from −π to π.One period of a sine wave, from −π to π.
canvas.graph{
    curve(expression: sin(x); domain: [-3.14, 3.14])
}

#Notes

  • Give a curve a node id — curve#flight(f: …) — to let cue.trace follow it with path: #flight.

Last updated