Creative coding script templates and starter sketches.
17 scripts
17 scripts
SDF
Signed distance fields describe shapes by how far any point is from their surface. That distance can be used to draw crisp outlines, blend shapes into each other, or shade entire scenes. A good entry point for raymarching and organic shape design.
2D Grid
The workhorse of generative art: even rows and columns computed from canvas size, padding, and cell counts. Each cell becomes a slot for a motif, a tile, or a decision. Start here for tilings, layouts, and repeating patterns.
Irregular Grid
Hexagon Grid
A hexagonal lattice built from axial coordinates, with the offset math handled for you. Hexagons pack tighter than squares and read as organic. The basis for honeycombs, game boards, and cellular compositions.
Hexagon Spiral
Voronoi Diagram
Scatters seed points and partitions the plane so every pixel belongs to its nearest seed. The result is a cellular structure that shows up everywhere in nature, from cracked mud to dragonfly wings. Uses d3 for the geometry.
Voronoi Clipped to Circle
Bowyer Watson Delaunay Triangulation
Lloyd's Relaxation
Circle Packing
Circles are placed at random positions and only kept if they fit without overlapping their neighbours. Repeated thousands of times this fills the canvas with a dense, organic arrangement. The classic introduction to packing algorithms.
Circle Packing Growing
Recursive Circle Packing
Polygon Packing
Like circle packing, but with arbitrary polygons: candidate shapes are placed at random and tested for intersection against everything already on the canvas. Shows how to do collision checks between polygon edges.
Particle System with Grid Lookup
A particle system that stores its particles in a spatial hash grid, so each one only checks its immediate neighbours instead of every other particle. This is the technique that keeps collision detection fast at high particle counts.
Reaction Diffusion
Two virtual chemicals react and diffuse across a grid following the Gray-Scott model, self-organising into stripes, spots, and labyrinths. Small parameter changes produce wildly different patterns. A classic of computational morphogenesis.
Quickhull Algorithm
Computes the convex hull of a scattered point set using the divide-and-conquer Quickhull method. Watch the hull emerge as the algorithm recursively finds the farthest points.
Polar Coordinates
Concentric rings of shapes placed with polar coordinates instead of x/y. A small change in radius and angle logic produces very different ring patterns.