# brainrot 008: double pendulum wall Live: https://brainrot.runfridge.dev/008/ Source: https://github.com/hwhang0917/brainrot/tree/main/008 License: MIT (see LICENSE at repo root); attribution only, no warranty. ## What it is A wall of double pendulums (30 by default) hung from one pivot and released at rest from almost the same angle, each nudged a hair further than the last. They swing as one for a moment, then chaos fans them apart into rainbow-coloured fading tip trails. Tap or drag on the canvas to set a new release angle (time freezes while dragging); sliders set the count (1-60) and the spread between neighbours (log scale, 0.001° to ~3.2°, default 0.1°); "re-sync" releases them again. No sound, no URL params. A HUD line shows count, release angle and seconds since release; CRT and hide-overlays buttons as on every page. ## How it was built - Rendering: pixi.js v8 `Application` (resizeTo window, DPR capped at 2), four `Graphics` layers (trails, arms, bobs, pivot) cleared and redrawn every tick. - Physics: classic double pendulum with unit masses and unit arms, g = 9.81, angles from straight down. Integrated with RK4 in fixed substeps of 1/1200 s per frame; frame dt capped at 0.05 s so a backgrounded tab does not fast-forward. Energy stays within 1e-3 relative over 20 s (tested). - Release: every pendulum starts with both arms at `angle + i * spread`, at rest; hue = i*360/count. Default angle 2.4 rad, high enough to flip. Pointer aim = atan2 of the pointer from the pivot. - Trails: last 180 tip points per pendulum, drawn in 6 bands of rising alpha to fake a fade. - History: one feature commit (the whole page landed at once), then the site-wide CRT mode and eye (hide HUD) button, then the move from /8/ to /008/ (public/8/index.html redirects). Vibe coded: prompted into existence with a coding agent, iterated commit by commit. ## Files - 008/index.html: page shell, meta/OG tags, inline CSS, back link, CRT button, HUD, hint, bottom bar (count/spread sliders, re-sync). - 008/main.ts: pixi setup, layout (ARM, PIVOT_Y), slider/pointer wiring, ticker that steps and draws; imports `hsl` from lib/color.ts, `mountCrt` from lib/crt.ts, `mountHud` from lib/hud.ts. - 008/pendulum.ts: pure model: `Pendulum` type, `step` (RK4 substeps), `positions`, `energy`, `release`. - 008/pendulum.test.ts: energy conservation, sensitive dependence (1e-4 rad apart: <0.05 after 1 s, >0.5 after 15 s), identical releases stay identical and hang straight at rest. ## Extending it - Run: `npm install && npm run dev`, open http://localhost:5173/008/ . Tests: `npm test`. Typecheck+build: `npm run build`. - Knobs: drawing/layout constants at the top of main.ts (ARM, PIVOT_Y, MAX_DT, TRAIL_LEN, TRAIL_BANDS, widths, BOB_R, DEFAULT_ANGLE, SPREAD_UNIT); physics constants (GRAVITY, SUBSTEP, masses, lengths) in pendulum.ts. Slider ranges live in index.html. - `positions` returns arm-length units with +y down; main.ts multiplies by `scale` (min screen side * ARM). - Keep `step` deterministic and energy-conserving: the tests rely on identical inputs giving identical outputs, and on the 1e-3 energy bound. A bigger SUBSTEP or a cheaper integrator will break them. - Any change to count, spread or angle calls `go()`, which rebuilds all pendulums and clears trails. - Conventions: keep pure simulation in its own module with a `node --test` file beside it; match the surrounding code style; Conventional Commits `type(008): message`.