12 From picture to recipe
Mirrors and kaleidoscopes: folding space
Draw one small motif and fold the coordinates so it appears many times: abs for mirror symmetry, mod on the polar angle for a kaleidoscope.
212
ExerciseTune values
Make this five-slice kaleidoscope
Runs once per pixelDrag numbers, or edit the code
JS side
gl.uniform2f(uResolution, …, …)Symmetry is not copying the shape; it is folding the coordinates. abs(p) folds four quadrants into one; taking mod of the polar angle and then abs cuts the circle into n mirrored slices. The shape code doesn’t change at all.
Try it
- Try all three folds: did the shape code change?
- In kaleidoscope mode, set the slices to 3, 8 and 12
- Open the pixel debugger and show a on the canvas: see how the angle is folded