Typst Fumadocs

Curve

Documentation for the `curve` function.

A curve consisting of movements, lines, and Bézier segments.

At any point in time, there is a conceptual pen or cursor.

  • Move elements move the cursor without drawing.
  • Line/Quadratic/Cubic elements draw a segment from the cursor to a new position, potentially with control point for a Bézier curve.
  • Close elements draw a straight or smooth line back to the start of the curve or the latest preceding move segment.

For layout purposes, the bounding box of the curve is a tight rectangle containing all segments as well as the point (0pt, 0pt).

Positions may be specified absolutely (i.e. relatively to (0pt, 0pt)), or relative to the current pen/cursor position, that is, the position where the previous segment ended.

Bézier curve control points can be skipped by passing none or automatically mirrored from the preceding segment by passing auto.

Example

Loading compiler...
#curve(
  fill: none | color | gradient | tiling,
  fill-rule: str,
  stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
  components
) -> content

Parameters

Prop

Type

Definitions

Starts a new curve component.

If no curve.move element is passed, the curve will start at (0pt, 0pt).

Loading compiler...
#curve.move(
  start,
  relative: bool
) -> content

Parameters

Prop

Type

Adds a straight line from the current point to a following one.

Loading compiler...
#curve.line(
  end,
  relative: bool
) -> content

Parameters

Prop

Type

Adds a quadratic Bézier curve segment from the last point to end, using control as the control point.

Loading compiler...
#curve.quad(
  control,
  end,
  relative: bool
) -> content

Parameters

Prop

Type

Adds a cubic Bézier curve segment from the last point to end, using control-start and control-end as the control points.

Loading compiler...
#curve.cubic(
  control-start,
  control-end,
  end,
  relative: bool
) -> content

Parameters

Prop

Type

Closes the curve by adding a segment from the last point to the start of the curve (or the last preceding curve.move point).

Loading compiler...
#curve.close(
  mode: str
) -> content

Parameters

Prop

Type

On this page