Pictures for the Shelf

Figures for the Shelf

Every picture the Shelf packages ask for is a figure: layers, the window of the plane they sit in, and a status that says how far the picture can be trusted. One figure goes to SVG, PNG, PDF, TikZ and text.

What a figure holds

figure({ layers, x, y, axes, equal, status, title, notes }) wraps the frames the scene renderers already draw. When x and y are left out the window is what the layers span, with a margin; equal: true keeps one unit the same length on both axes, so circles stay round. figureSVG(fig, { width, height }), figurePNG, figurePDF, figureTikZ and figureASCII draw it at a size; a figure may carry a size hint of its own (a proof tree knows how wide its formulas are).

Four statuses

A picture makes claims, and the status says what kind:

  • exact: every mark is at the exact value (exact data, exact layout). A payoff diagram drawn through its kinks, a Tutte drawing with rational coordinates, a proof tree.
  • certified: every mark is within a stated error, or a pixel's class is proved. An escape-time picture whose undecided pixels have their own colour.
  • estimated: floating-point values, not proved. A phase portrait's orbits, a spring layout, a density curve. Any certified number in the picture (an equilibrium, a shaded probability) is said in notes.
  • simulated: the result of seeded random runs. The same seed draws the same picture; another seed a different one.

Two new frames

shapes([...]) is a frame of styled shapes in world coordinates, made by path(points, style), dot(at, style), arrow(from, to, style) and text(at, tex, style). image({ x, y, width, height, cells }) is a grid of coloured cells, row 0 at the bottom, with runs of one colour merged into one rectangle. Escape-time pictures, Venn shading and stability regions are images.

Frames to animate

Functions that build a sequence (a sampling distribution growing, a moving frame, a heat solution in time, a construction step by step) return { kind: "frames", frames }. framesSVG turns them into one animated SVG that plays with no script; framesPNG into an animated PNG.

Polygons and solids

polygonsFigure(polygons, { colorBy }) fills polygons, coloured by their number of sides or by a key; solidFigure(vertices, faces) lights a polyhedron's faces and sorts them by depth in a box that keeps the solid's proportions. The geometry package computes tilings and solids and draws them with these.

Try itEdit the code and run it with @ratmath/graphics and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math, and SHOW(svg) draws a picture.
Ctrl/⌘ + Enter runs