Life getting you down? Calm your nerves with the soothing power of shapes.
Controls
hold WASD or drag
steer
hold QE
roll counterclockwise or clockwise
wheel, pinch, +−
zoom
[]
previous or next shape
,.
previous or next effect
R
reroll
Space
pause
L
lights
I
this panel
Effects
A canvas has no sense of depth. It paints each new shape over what is already there. Showing which face is in front is up to the program.
Wireframe. Only the edges. Edges on the far side are dashed.
Solid. Faces turned away from you are skipped. The rest are painted far to near so near faces cover far ones. This is the painter's algorithm. Each face is lit by how squarely it faces the light (Lambert shading). A surface open on both sides shows its back in a second color. On the Möbius strip and the Klein bottle the color flips along a line. That line is where front and back meet, because these surfaces have only one side.
One op. Faces are painted far to near. Every face mixes with the faces behind it through the same composite operation.
Mixed ops. Faces are painted in the order the shape lists them. Nothing checks which face is nearer. A face at the back can land on top of one at the front. Each face mixes with the paint below it through its own composite operation. Ops that clear the canvas only go to the first 26 faces. Otherwise the last face would clear the rest.
Seven ops need a destination to act on: source-in, source-out, source-atop, destination-in, destination-out, destination-atop, copy. On empty canvas they draw nothing or plain shape. These draw onto gray transparency grid filled inside shape's outline. Faces are inset so grid shows between them.
Math
Orientation is one unit quaternion renormalized every frame.
Projection is x × f / (d + z) with the eye 6 units back.
Euler characteristicχ = V − E + F. Sphere-like shapes give 2. The flat triangle gives 1. The torus, the trefoil knot, and the Möbius strip give 0.
The hypercube and the 16-cell turn in 4D and are projected to 3D in perspective. They are drawn as their squares and triangles. The hypercube gives 8 and the 16-cell 16. Subtract their cells for 0.
The Klein bottle gives 0 like the torus but has one side. The Enneper surface is a disk and gives 1. The double torus has two holes and gives −2.
The dodecahedron is the dual of the icosahedron. The geodesic sphere is the icosahedron split twice. The other convex shapes come from a convex hull of their corners.
Glossary
Composite operation
The rule for mixing a new drawing with what the canvas already holds. The canvas has 26.
Source
What is being drawn now. Here a face or the whole shape.
Destination
What the canvas holds before the source lands.
Alpha
How opaque a pixel is. 0 is clear. 1 is solid.
Porter-Duff ops
The source and destination ops plus xor, copy, and lighter. They decide which pixels survive by alpha alone. Named for the 1984 paper by Porter and Duff that set them out: Compositing Digital Images.
Blend modes
Multiply through luminosity. They mix the colors where source and destination overlap.
Vertex, edge, face
A corner, the line between two corners, and a flat polygon bounded by edges.
Culling
Skipping faces that point away from the eye.
Painter's algorithm
Drawing far faces first so near ones cover them.
Perspective
Dividing by depth so far points crowd toward the middle.
Quaternion
Four numbers that hold a rotation without drift or gimbal lock.
Credits
Original rotation adapted from a gist by Thomas Darimont.