Monocurl
Download

std.mesh

mesh.mcl

Reference for the symbols exported by mesh.mcl.

Index

Primitive Constructors

Three D Primitives

Visual / Graphical

Text / Labels

Graphing

Layout / Grouping

Transform Operators

operator shiftimportant Translate a mesh by a vector. operator strokeimportant Set stroke color and optional stroke width. operator fillimportant Set fill color. operator colorimportant Recolor both fill and stroke where applicable. operator tagimportant Replace mesh tags, optionally filtered by existing tags. operator point_mapimportant Map every point of a mesh through a function. operator centerimportant Move a mesh so its center lies at a point. operator to_sideimportant Move a mesh near one side of the camera frame. operator to_cornerimportant Move a mesh near a corner of the camera frame. operator next_toimportant Place a mesh next to a reference mesh. operator tag_filterimportant Keep only mesh leaves matching a tag filter. operator scale Scale a mesh uniformly or per axis. operator rotate Rotate a mesh around an axis and optional pivot. operator fade Multiply mesh opacity by an opacity value. operator dotted Set dotted stroke color. operator normal_hint Override the normal hint used for rendering or strokes. operator textured Apply an image texture to a mesh. operator z_index Assign a draw ordering hint to a mesh. operator gloss Add glossy lighting amount to a mesh. operator color_map Map mesh colors through a function. operator uv_map Map mesh UV coordinates through a function. operator tag_map Map mesh tags through a function. operator subset_map Apply a mapping function only to tag-filtered subsets. operator uprank Promote lower-dimensional topology into higher-dimensional topology. operator downrank Demote higher-dimensional topology into lower-dimensional topology. operator wireframe Convert surface-like geometry to wireframe display. operator dashed Convert strokes to dashed strokes. operator subdivide Subdivide mesh geometry for smoother downstream transforms. operator tesselated Tessellate mesh geometry to the requested depth. operator extrude Extrude a mesh by a delta vector. operator revolve Revolve mesh geometry around an axis rotation. operator camera_transfer Keep a mesh fixed relative to the frame while camera changes. operator matched_edge Place one edge of a mesh against an edge of a reference mesh. operator projected Project a screen-space point along a ray into mesh space. operator in_space Interpret a mesh inside a local coordinate space. function tag_split Split a mesh into [matching, non_matching] by tag filter. function mesh_collapse Collapse nested mesh lists into a flatter mesh. operator contour_separate Separate contours so morphing can treat them independently. function trans Compute an intermediate Trans morph value between two meshes. function bend Compute an intermediate Bend morph value between two meshes.

Queries

Primitive Constructors

importantconstructor

A circle centered at the origin in the XY plane. Apply stroke or fill operators to style it, and shift to reposition.

let Circle = |radius, samples = 64| ...
samplesnumber of line segments used to approximate the curve (default 64)
imagedoc-mesh-circle-1.mcl
rendered monocurl scene
mesh c = stroke{CYAN} Circle(1.5)
importantconstructor

A square centered at the origin with sides parallel to the axes.

let Square = |width| ...
mesh box = fill{alpha{0.2} ORANGE} stroke{ORANGE} Square(1.1)
importantconstructor

An axis-aligned rectangle centered at the origin.

let Rect = |size| ...
size[width, height]
mesh card = fill{alpha{0.12} BLUE} stroke{BLUE} Rect([2.0, 0.8])
importantconstructor

A directed arrow from start to end, with an arrowhead at the tip.

path_arc bends the shaft by rotating along a circular arc instead of a straight segment. Its sign is relative to normal; use 0 for a straight arrow.

let Arrow = |start = [0, 0, 0], end = [1, 0, 0], normal = 1b, path_arc = 0| ...
starttail position, default origin
endtip position, default [1, 0, 0]
normalpreferred plane normal for the arrow body
path_arcsigned arc angle in radians, default 0
mesh curved = color{ORANGE} Arrow(1.2l, 1.2r, 1b, PI / 3)
constructor

A single point in 3-D space, rendered as a viewport-facing dot.

Unlike most line/surface primitives, Dot has a visible default radius; topology dots created internally by other constructors are invisible unless styled.

let Dot = |point = [0, 0, 0]| ...
mesh p = fill{CYAN} Dot([1, 0, 0])
constructor

A filled annulus between two concentric circles in the XY plane.

The inner loop is authored as a hole, so fill/stroke operators style the ring as one surface with a boundary.

let Annulus = |inner, outer| ...
mesh ring = fill{alpha{0.18} CYAN} stroke{CYAN} Annulus(0.7, 1.0)
constructor

A regular n-gon inscribed in a circle of the given circumradius, centered at the origin.

let RegularPolygon = |n, circumradius| ...
nclamped to at least 3 sides
mesh pentagon = RegularPolygon(5, 0.8)
constructor

A closed polygon from an ordered list of vertices.

The vertex loop is tessellated into a filled surface. Use Polyline for an open path or downrank{} when you want only the boundary.

let Polygon = |vertices, normal_hint = 1b| ...
normal_hintpreferred face orientation; defaults to 1b
mesh poly = fill{alpha{0.2} GREEN} Polygon([LEFT, UP, RIGHT, DOWN])
constructor

An open polyline through the given vertices.

let Polyline = |vertices, normal_hint = 1b| ...
normal_hintpreferred stroke normal; defaults to 1b
mesh path = stroke{TEAL, 3} Polyline([1.2l, 0.4u, 1.2r])
constructor

A straight line segment between two points.

let Line = |start = [0, 0, 0], end = [1, 0, 0], normal = 1b| ...
normalpreferred stroke normal, used by lighting and topology transforms
mesh l = stroke{WHITE} Line([0,0,0], [2,1,0])
constructor

Circular arc centered at the origin in the XY plane.

theta is [start_angle, end_angle] in radians. The sampled stroke includes both endpoints.

let Arc = |radius = 1, theta = [0, 3.14159265358979]| ...
theta[start, end] angles in radians
mesh arc = stroke{CYAN} Arc(1, [0, PI])
constructor

Rounded filled capsule between two cap centers.

radii may be one number for a constant-width capsule or [start_radius, end_radius] for a tapered capsule.

let Capsule = |start_center, end_center, radii = 0.4, normal = 1b| ...
radiisingle radius or [start_radius, end_radius]
normalpreferred plane normal
mesh pill = fill{alpha{0.18} BLUE} Capsule(LEFT, RIGHT, 0.25)
constructor

Filled triangle from three vertices.

normal_hint controls the preferred winding/lighting side.

let Triangle = |p, q, r, normal_hint = 1b| ...
normal_hintpreferred face orientation
mesh tri = fill{alpha{0.2} PURPLE} Triangle(1l, 1r, 1u)

Three D Primitives

constructor

3-D sphere centered at the origin.

sample_depth controls subdivision; higher values add triangles quickly.

let Sphere = |radius, sample_depth = 2| ...
sample_depthsubdivision depth, clamped to at least 0
mesh globe = fill{alpha{0.2} BLUE} stroke{BLUE} Sphere(0.8)
constructor

Rectangular prism centered at the origin.

let RectangularPrism = |dimensions| ...
dimensions[width, height, depth]
constructor

Cylinder oriented along a direction.

The cylinder is centered at the origin. A zero direction falls back to the y axis.

let Cylinder = |radius, height, direction = 1u, sample_count = 32| ...
sample_countradial samples, clamped to at least 3
constructor

Cone from apex to base center.

let Cone = |apex = [0, 1, 0], base = [0, 0, 0], radius = 1, sample_count = 32| ...
sample_countradial samples, clamped to at least 3
constructor

Torus centered at the origin in the XY plane.

let Torus = |radii = [1, 0.3], samples = [48, 24]| ...
radii[major_radius, minor_radius]
samples[major_samples, minor_samples], each clamped to at least 3
constructor

Rectangular plane in the XY plane, offset along 1b.

let Plane = |dist = 0, size = [4, 4]| ...
size[width, height]

Visual / Graphical

importantconstructor

Sample a color function over a rectangular grid.

By default each visible cell gets one flat color sampled at the cell corner. Pass smooth = 1 to color vertices for smooth interpolation, or pass a callable as the fourth argument to use it as the mask while keeping flat colors. color_at receives (pos, [ix, iy]); mask receives pos.

let ColorGrid = |color_at, x_min_max_samples = [-1, 1, 21], y_min_max_samples = [-1, 1, 21], smooth = 0, mask = |pos| 1| ...
color_atfunction from cell 3d position and 2d index to RGBA color
x_min_max_samples[x_min, x_max, samples]
y_min_max_samples[y_min, y_max, samples]
smoothtruthy for vertex color interpolation, falsey for flat cells, or a mask function
maskoptional function deciding which positions render
mesh heat = ColorGrid(|p, idx| hsv(norm(p) / 2, 0.7, 0.9), [-2, 2, 60], [-1, 1, 30])
importantconstructor

Build a rectangular grid of line segments.

The result is one mesh with subdivided line topology, which makes later point_map and Trans operations smoother.

let LineGrid = |x_min_max_samples = [-1, 1, 21], y_min_max_samples = [-1, 1, 21], subdivision = 16| ...
x_min_max_samples[x_min, x_max, samples]
y_min_max_samples[y_min, y_max, samples]
subdivisionsubdivisions per grid segment
mesh grid = stroke{LIGHT_GRAY} LineGrid([-2, 2, 9], [-1, 1, 5])
importantconstructor

Sample a mesh-producing function over a rectangular field.

mesh_at receives (pos, [ix, iy]); mask receives pos. Calls are batched internally, so this is the preferred way to build repeated arrows/glyphs on a grid.

let Field = |mesh_at, x_min_max_samples = [-1, 1, 21], y_min_max_samples = [-1, 1, 21], mask = |pos| 1| ...
mesh_atfunction from position and index to a mesh
x_min_max_samples[x_min, x_max, samples]
y_min_max_samples[y_min, y_max, samples]
maskoptional function deciding which subset of cells to include
mesh arrows = Field(|p, idx| Arrow(p, p + 0.2 * normalize(p)), [-2, 2, 12], [-1, 1, 7])
constructor

Bezier curve through control points, sampled as a 64-segment stroke.

With fewer than two control points this returns an empty mesh.

let Bezier = |control_points| ...
mesh curve = stroke{MAGENTA, 3} Bezier([1.4l, 1u, 1.4r])
constructor

Arrow-like vector from a tail by a delta.

The arrowhead and shaft proportions are adjusted for short vectors so fields stay legible.

let Vector = |delta = 1r, tail = [0, 0, 0], normal = 1b| ...
mesh v = color{CYAN} Vector(0.8r + 0.4u, ORIGIN)
constructor

Simple line segment from tail to tail + delta.

Use this for dense fields when arrowheads would clutter the scene.

let HalfVector = |tail = [0, 0, 0], delta = 1r, normal = 1b| ...
constructor

Place a bundled or project image into the scene.

The image is rendered as a textured upright rectangle in the XY plane. name may be a bundled asset name or a project-relative path resolved by the runtime.

let Image = |name, center = [0, 0, 0], size = [1, 1]| ...
nameimage asset name or path, relative to the currently invoked scene or library
centerimage center
size[width, height]
mesh logo = Image("monocurl-1024.png", ORIGIN, [1.2, 1.2])

Text / Labels

importantconstructor

Plain text converted to mesh geometry.

Use Text for literal text. It still returns mesh geometry, so Write, Fade, tag_filter, and styling operators all apply.

let Text = |text, scale = 1| ...
imagedoc-mesh-text-1.mcl
rendered monocurl scene
mesh title = center{UP} Text("Monocurl", 0.8)
importantconstructor

Math text converted through TeX into mesh geometry.

let Tex = |tex, scale = 1| ...
texTeX math fragment, string/list text fragments, or text_tag{...} fragments
mesh eq = Tex("a^2 + b^2 = c^2", 0.8)
importantconstructor

Measurement marker drawn next to a target mesh.

Builds a stroke spanning the target's bounds perpendicular to dir, offset by buffer.

let Measure = |target, dir = 1d, buffer = 0.15| ...
mesh width = [seg, Measure(seg, DOWN), Label(seg, "w", DOWN)]
constructor

Full LaTeX fragment converted into mesh geometry.

Use this when the input already contains document-level LaTeX structure; use Tex for ordinary displayed math.

let Latex = |latex, scale = 1| ...
operator

Attach tags to text fragments before they become mesh contours.

Use text tags for equation transforms and selective coloring inside Tex/Latex. The tag can be an integer or a list of integers; the wrapper lowers to the LaTeX \text_tag{...}{...} marker before rendering.

let text_tag = operator |target, tag| ...
mesh eq = Tex([text_tag{1} "x", " + ", text_tag{2} "1"], 0.8)
constructor

Brace drawn next to a target mesh.

Reserved wrapper; the native implementation is not complete yet. Prefer Measure plus Label for current scenes.

let Brace = |target, dir = 1d, buffer = 0.15| ...
constructor

Text label placed relative to a target mesh.

The label is rendered as LaTeX, then placed outside the target in dir while staying centered on the target's orthogonal direction.

let Label = |target, str, dir = 1u, scale = 1, buffer = 0.1| ...
bufferdistance from target
mesh labeled = [seg, Label(seg, "length", UP)]
constructor

Number rendered as text with optional formatting.

With decimal_places = nil, formatting uses compact %g-style output. Set include_sign truthy for a leading plus sign on positive values.

let Number = |value, decimal_places = nil, include_sign = 0| ...
decimal_placesoptional fixed decimal count
include_signinclude plus sign for positive values
mesh n = Number(value, 2, 1)

Graphing

importantoperator

Pre-fill axis options on an axis constructor.

This is a configuration operator; compose it before Axis1d, Axis2d, or Axis3d. It uses set_default internally, so axis settings interpolate cleanly when the axis is animated.

let axis_style = operator |target, axis, min, max, axis_title = nil, tick_spacing = 0.25, major_tick_rate = 4, label_map = (|x| x), arrow_extrusion = 0.2| ...
axis"x", "y", or "z"
tick_spacingdistance between ticks in axis coordinates
major_tick_rateevery nth tick is drawn/labelled as major
label_mapfunction from value to tick label
arrow_extrusionarrowhead length in scene units
mesh axes = axis_style{"x", 0, 4, "x"} axis_style{"y", 0, 3, "y"} Axis2d()
importantconstructor

Two-dimensional coordinate axes, optionally with grid lines.

basis gives the scene-space x/y unit vectors for the graph. Use grid_color to draw grid lines; leave it nil for ticks only.

let Axis2d = |basis = [1r, 1u], color = [0, 0, 0, 1], grid_color = nil, x_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2], y_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2]| ...
imagedoc-mesh-axis2d-1.mcl
rendered monocurl scene
mesh axes = axis_style{"x", -2, 2, "x"} axis_style{"y", -1, 3, "f(x)"} Axis2d()
importantconstructor

Sample y = f(x) as a polyline in the XY plane.

Endpoints are included. Use in_space{...} to embed the graph into a custom axes coordinate system.

let ExplicitFunc = |f, x_min_max_samples = [-5, 5, 128]| ...
imagedoc-mesh-explicitfunc-1.mcl
rendered monocurl scene
mesh graph = stroke{CYAN} ExplicitFunc(|x| sin(x), [-PI, PI, 160])
constructor

One-dimensional axis mesh along a basis vector.

Usually configured through axis_style{"x", ...} rather than by manually editing the compact x_axis style list.

let Axis1d = |basis = 1r, normal = 1b, color = [0, 0, 0, 1], x_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2]| ...
constructor

Three-dimensional coordinate axes, optionally with grid lines.

label_up controls how tick labels and titles are oriented per axis; pass three up vectors when default text orientation is not readable from the active camera.

let Axis3d = |basis = [1r, 1u, 1b], color = [0, 0, 0, 1], grid_color = nil, label_up = [1u, 1u, 1b], x_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2], y_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2], z_axis = [-5, 5, nil, 0.25, 4, |x| x, 0.2]| ...
mesh axes = axis_style{"z", 0, 2, "z"} Axis3d(label_up: [1u, 1u, 1b])
constructor

Polar coordinate axis mesh.

theta and radius are [min, max, unit, tick_step]; radius values are clamped to non-negative.

let PolarAxis = |center = [0, 0, 0], theta = [-5, 5, 1, 1], radius = [0, 5, 1, 1]| ...
constructor

Sample a 3-D parametric curve function.

The function receives t and must return a 3-D point. Endpoints are included.

let ParametricFunc = |f, t_min_max_samples = [0, 1, 64]| ...
t_min_max_samples[t_min, t_max, samples]
mesh spiral = stroke{CYAN} ParametricFunc(|t| [cos(t), sin(t), t / TAU], [0, TAU * 3, 180])
constructor

Sample z = f(x, y) as a 3-D surface.

The function receives (x, y) and returns z. The domain lists are [min, max, samples].

let ExplicitFunc2d = |f, x_min_max_samples = [-1, 1, 21], y_min_max_samples = [-1, 1, 21]| ...
mesh surface = ExplicitFunc2d(|x, y| x * x + y * y, [-1, 1, 31], [-1, 1, 31])
constructor

Sample an implicit 2-D contour f(x, y) = 0.

Uses a rectangular sampling grid and extracts zero contours as strokes; increase sample counts for sharper features.

let ImplicitFunc2d = |f, x_min_max_samples = [-1, 1, 41], y_min_max_samples = [-1, 1, 41]| ...
mesh level = stroke{CYAN} ImplicitFunc2d(|x, y| x * x + y * y - 1)
constructor

Fill the signed area between two explicit functions.

Returns two tagged filled regions, one for where f is below g and one for where it is above. This is useful for shaded inequalities or visualizing approximation error.

let ExplicitFuncDiff = |f, g, x_min_max_samples = [-5, 5, 128], fills = [[0.3, 0.8, 0.3, 0.5], [0.8, 0.3, 0.3, 0.5]], tags = [[], []]| ...
x_min_max_samples[x_min, x_max, samples]
fills[lower_fill, upper_fill]
tagstags assigned to the two filled regions
mesh diff = ExplicitFuncDiff(|x| sin(x), |x| 0, [-PI, PI, 160])

Layout / Grouping

constructor

Lay meshes out in a line along a direction.

Items are placed touching along dir with a small built-in gap. align_dir can pin one side of each item to a common line.

let Stack = |meshes, dir, align_dir = [0, 0, 0]| ...
align_diroptional direction whose extreme edge should be aligned
mesh row = XStack([Circle(0.2), Square(0.4), Text("x")])
constructor

Stack meshes along the x axis.

let XStack = |meshes, align_dir = [0, 0, 0]| Stack(meshes, 1r, align_dir)
constructor

Stack meshes along the y axis.

let YStack = |meshes, align_dir = [0, 0, 0]| Stack(meshes, 1u, align_dir)
constructor

Stack meshes along the z axis.

let ZStack = |meshes, align_dir = [0, 0, 0]| Stack(meshes, 1b, align_dir)
constructor

Return a nested mesh list unchanged for grid-style grouping.

Currently this is a semantic wrapper around nested mesh lists; it does not auto-position cells.

let Grid = |mesh_array| ...
constructor

Return a nested mesh list unchanged for table-style grouping.

Currently aliases Grid.

let Table = |mesh_array| ...
constructor

Rectangle around the visible bounds of a mesh.

Builds a filled rectangle in the XY plane at the target bounds' z value. Style it with fill{CLEAR}/stroke{...} for an outline.

let BoundingBox = |target, buffer = 0.1| ...
mesh boxed = [label, fill{CLEAR} stroke{CYAN} BoundingBox(label, 0.08)]

Transform Operators

importantoperator

Translate a mesh by a vector.

Most primitive constructors are authored at the origin; shift is the lightweight way to place them without changing their local parameters.

let shift = operator |target, delta, filter = nil| ...
filteroptional tag predicate applied to mesh leaves
mesh moved = shift{2r + 1u} Circle(0.4)
importantoperator

Set stroke color and optional stroke width.

If stroke_width is nil, existing stroke widths are preserved. When you need a filter and no width change, call stroke{color, nil, filter}.

let stroke = operator |target, color, stroke_width = nil, filter = nil| ...
stroke_widthoptional width; nil preserves existing width
filteroptional tag predicate
mesh outline = fill{CLEAR} stroke{CYAN, 2} Circle(1)
importantoperator

Set fill color.

Applies to filled surfaces and dots; use color{...} when you want to recolor fill, stroke, and dots together.

let fill = operator |target, color, filter = nil| ...
filteroptional tag predicate
mesh disk = fill{alpha{0.2} BLUE} Circle(1)
importantoperator

Recolor both fill and stroke where applicable.

Useful for fading a whole mesh tree into a muted state without separately touching fill and stroke.

let color = operator |target, color, filter = nil| ...
mesh muted = color{LIGHT_GRAY, |tags| not (2 in tags)} group
importantoperator

Replace mesh tags, optionally filtered by existing tags.

Tags are stable identities for filters and tag-aware animations. A scalar tag becomes a one-element tag list; a list can give one mesh several identities.

let tag = operator |target, tag, filter = nil| [target, __monocurl__native__ op_retagged(target, |old| ...
mesh pair = [tag{1} Circle(0.3), tag{2} Square(0.4)]
importantoperator

Map every point of a mesh through a function.

The callback receives a 3-D point and should return a 3-D point. Callback invocations are batched internally for mesh-sized transforms.

let point_map = operator |target, f, filter = nil| ...
mesh lifted = point_map{|p| [p[0], p[1], p[0] * p[0]]} LineGrid()
importantoperator

Move a mesh so its center lies at a point.

Centers by bounding-box center, not by centroid.

let center = operator |target, center, filter = nil| ...
mesh title = center{1.2u} Text("Title", 0.8)
importantoperator

Move a mesh near one side of the camera frame.

Placement is camera-aware, so to_side{UP} means the top of the rendered frame rather than global +y when a camera is supplied.

let to_side = operator |target, dir = [0, 0, 0], buffer = 0.1, camera = nil, filter = nil| ...
dirside direction, such as 1u or 1d
bufferdistance from the side
cameraoptional camera, default current camera
mesh caption = to_side{DOWN, 0.2} Text("caption", 0.5)
importantoperator

Move a mesh near a corner of the camera frame.

dir chooses the corner by signs, for example UP + RIGHT or [1, 1, 0].

let to_corner = operator |target, dir = [1, 1, 0], buffer = 0.1, camera = nil, filter = nil| ...
mesh badge = to_corner{UP + RIGHT, 0.2} Text("1")
importantoperator

Place a mesh next to a reference mesh.

Like matched_edge, but adds buffer spacing between the two bounding boxes.

let next_to = operator |target, ref, dir = 1r, buffer = 0.1, filter = nil| ...
buffergap between meshes
mesh label = next_to{base, RIGHT, 0.2} Text("area")
importantoperator

Keep only mesh leaves matching a tag filter.

The filter receives the full tag list for each mesh leaf, not one tag at a time.

let tag_filter = operator |target, filter| ...
mesh selected = tag_filter{|tags| 2 in tags} group
operator

Scale a mesh uniformly or per axis.

A scalar factor scales all coordinates. A 3-list scales x/y/z independently.

let scale = operator |target, factor = 1, filter = nil| ...
factorscalar or vector scale
filteroptional tag predicate applied to mesh leaves
mesh wide = scale{[2, 0.5, 1]} Circle(0.5)
operator

Rotate a mesh around an axis and optional pivot.

Rotation is interpolatable because the operator supplies identity and target rotation states to Lerp.

let rotate = operator |target, radians, axis = 1b, pivot = nil, filter = nil| ...
axisrotation axis, default 1b
pivotoptional point to rotate around; defaults to the origin
mesh spun = rotate{PI / 4, 1b} Square(1)
operator

Multiply mesh opacity by an opacity value.

This scales existing alpha channels; it does not replace them.

let fade = operator |target, opacity, filter = nil| ...
operator

Set dotted stroke color.

Dots are rendered at line vertices; this is separate from dashed, which rewrites line geometry into dash segments.

let dotted = operator |target, color, filter = nil| ...
operator

Override the normal hint used for rendering or strokes.

This changes normal hints on dots and lines. It is useful after custom geometry mapping if lighting or stroke orientation looks wrong.

let normal_hint = operator |target, normal, filter = nil| ...
operator

Apply an image texture to a mesh.

Usually used by Image; applying it manually expects the mesh to have meaningful UV coordinates.

let textured = operator |target, image, filter = nil| ...
operator

Assign a draw ordering hint to a mesh.

Higher z-index values draw later among otherwise comparable meshes.

let z_index = operator |target, z_index, filter = nil| ...
operator

Add glossy lighting amount to a mesh.

Mainly visible on filled 3-D surfaces.

let gloss = operator |target, amount = 0.5, filter = nil| ...
operator

Map mesh colors through a function.

The callback receives an RGBA color and should return an RGBA color.

let color_map = operator |target, f, filter = nil| ...
operator

Map mesh UV coordinates through a function.

The callback receives a UV pair and should return a UV pair; mostly useful for textured meshes.

let uv_map = operator |target, f, filter = nil| ...
operator

Map mesh tags through a function.

The callback receives the full tag list for each mesh leaf and should return a replacement tag or tag list.

let tag_map = operator |target, f| ...
operator

Apply a mapping function only to tag-filtered subsets.

The filter selects mesh leaves by their tag list; the mapper receives each selected leaf as a mesh value and should return the replacement mesh.

let subset_map = operator |target, filter, f| ...
mesh emphasized = subset_map{|tags| 2 in tags, |m| scale{1.2} m} group
operator

Promote lower-dimensional topology into higher-dimensional topology.

uprank turns point chains into line segments and closed line contours into tessellated filled surfaces. It is useful before operations that expect surfaces, such as extrude, or when a closed outline should become fillable.

let uprank = operator |target, filter = nil| ...
mesh disk = fill{alpha{0.16} CYAN} uprank{} Polyline([1l, 1u, 1r, 1d, 1l])
operator

Demote higher-dimensional topology into lower-dimensional topology.

downrank turns surfaces into boundary strokes and strokes into endpoint dots. Use it for outlines/wire geometry, or to expose a filled shape's boundary for stroke-only proofs and construction diagrams.

let downrank = operator |target, filter = nil| ...
mesh outline = stroke{WHITE} fill{CLEAR} downrank{} Rect([2, 1])
operator

Convert surface-like geometry to wireframe display.

Alias for downrank.

let wireframe = operator |target, filter = nil| ...
operator

Convert strokes to dashed strokes.

Rewrites line geometry into dash segments while preserving fills and dots in the same mesh tree. A scalar lengths value uses the same dash and gap length.

let dashed = operator |target, lengths = [0.2, 0.1], offset = 0, filter = nil| ...
lengthsdash length or [dash, gap]
offsetphase offset
filteroptional tag predicate
mesh guide = dashed{[0.15, 0.08]} stroke{LIGHT_GRAY} Line(1.5l, 1.5r)
operator

Subdivide mesh geometry for smoother downstream transforms.

Adds intermediate samples to lines/surfaces without changing the intended shape. Useful before point_map, Trans, or nonlinear deformations.

let subdivide = operator |target, factor = 2, filter = nil| ...
operator

Tessellate mesh geometry to the requested depth.

Splits surface triangles repeatedly; use it before curved point_map deformations.

let tesselated = operator |target, depth = 1, filter = nil| ...
operator

Extrude a mesh by a delta vector.

Builds side walls from surface boundaries. Standalone closed line loops must be uprank{}ed first so the extruder sees a surface.

let extrude = operator |target, delta, filter = nil| ...
mesh block = extrude{0.5b} Square(1)
operator

Revolve mesh geometry around an axis rotation.

Sweeps geometry around the rotation vector; larger rotation magnitude sweeps farther around the axis.

let revolve = operator |target, rotation, filter = nil| ...
operator

Keep a mesh fixed relative to the frame while camera changes.

Remaps mesh positions from original_camera to live_camera so the mesh keeps the same apparent screen placement during camera motion. Use this for overlays, labels, and callouts that should not drift while the camera lerps.

let camera_transfer = operator |target, original_camera, live_camera, filter = nil| ...
original_cameracamera used when the mesh was authored
live_cameracurrent or stateful camera, often $camera
mesh hud = camera_transfer{camera, $camera} to_side{UP} Text("fixed")
operator

Place one edge of a mesh against an edge of a reference mesh.

Moves the target so its -dir edge sits on the reference mesh's dir edge.

let matched_edge = operator |target, ref, dir, filter = nil| ...
operator

Project a screen-space point along a ray into mesh space.

Casts from each target point along ray and snaps to the nearest triangle hit in the screen mesh. Points that miss are unchanged.

let projected = operator |target, screen, ray = 1b, filter = nil| ...
operator

Interpret a mesh inside a local coordinate space.

Maps each point p to axis_center + x_unit * p.x + y_unit * p.y + z_unit * p.z, and remaps dot/line normal hints through the same basis. This is commonly used to build graphs in axis coordinates and then embed them into global scene coordinates.

let in_space = operator |target, axis_center = [0, 0, 0], x_unit = 1r, y_unit = 1u, z_unit = 1b, filter = nil| ...
axis_centerlocal origin
x_unitlocal x basis
y_unitlocal y basis
z_unitlocal z basis
let graph_space = operator |target| in_space{[-1.2, -1.0, 0], 0.45r, 0.45u} target
mesh graph = graph_space{} ExplicitFunc(|x| x * x, [0, 3, 80])
function

Split a mesh into [matching, non_matching] by tag filter.

Useful for transfer animations and custom progressors that need to move part of a mesh tree.

let tag_split = |target, filter = nil| ...
function

Collapse nested mesh lists into a flatter mesh.

Preserves geometry while reducing mesh-tree nesting.

let mesh_collapse = |target| ...
operator

Separate contours so morphing can treat them independently.

Flattens contour-separated leaves and tags them [0], [1], ... in output order, making later tag_filter selections deterministic.

let contour_separate = operator |target| ...
function

Compute an intermediate Trans morph value between two meshes.

This is the pure value form behind the Trans animation. path_arc bends point paths through circular arcs; pass 0 for straight-line motion or a 3-vector whose direction chooses the arc plane and whose length is the arc angle in radians.

let trans = |start, end, t, path_arc = 0, similar_topo_hint = 0| ...
path_arc0 or a 3-vector arc control
similar_topo_hinttruthy to try exact topology matching first
let halfway = trans(Square(1), Circle(0.7), 0.5, 0.6b)
function

Compute an intermediate Bend morph value between two meshes.

Pure value form behind Bend; best for line/path geometry where local tangent rotation matters.

let bend = |start, end, t| ...

Queries

function

Left x bound of a mesh.

let mesh_left = |target| ...
function

Right x bound of a mesh.

let mesh_right = |target| ...
function

Up y bound of a mesh.

let mesh_up = |target| ...
function

Down y bound of a mesh.

let mesh_down = |target| ...
function

Forward z bound of a mesh.

let mesh_forward = |target| ...
function

Backward z bound of a mesh.

let mesh_backward = |target| ...
function

Extreme bound of a mesh along a direction.

let mesh_direc = |target, direc| ...
function

Width of a mesh bounding box.

let mesh_width = |target| ...
function

Height of a mesh bounding box.

let mesh_height = |target| ...
function

Center of a mesh bounding box.

let mesh_center = |target| ...
function

Topological rank of a mesh: 0 for dots, 1 for lines, 2 for surfaces.

uprank and downrank move geometry between these ranks.

let mesh_rank = |target| ...
function

Tags present in a mesh.

let mesh_tags = |target| ...
function

Sample a point on a mesh at normalized position t.

Samples by authored geometry order; for multi-contour meshes, use contour_separate{} first when each contour needs its own sampling domain.

let mesh_sample = |target, t| ...
function

Sample a normal on a mesh at normalized position t.

let mesh_normal = |target, t| ...
function

Sample a tangent on a mesh at normalized position t.

let mesh_tangent = |target, t| ...
function

Test whether a mesh contains a point.

Primarily meaningful for filled planar/surface geometry.

let mesh_contains = |target, point| ...
function

Distance from a point to a mesh.

let mesh_dist = |target, test_point| ...
function

Raycast against a mesh from a source along a direction.

Returns the closest hit point along the ray when a triangle is hit.

let mesh_raycast = |target, src, direction| ...
function

Raw vertex set of a mesh.

Low-level topology inspection; prefer bounds and sampling helpers for ordinary layout.

let mesh_vertex_set = |target| ...
function

Raw edge set of a mesh.

Low-level topology inspection.

let mesh_edge_set = |target| ...
function

Raw triangle set of a mesh.

Low-level topology inspection.

let mesh_triangle_set = |target| ...
function

Number of contours in a mesh.

let mesh_contour_count = |target| ...