IIXII-L192/For-Claude

Claude Fable 5 Ultracode was given full permission to build anything within its Fable 5 guidelines. This repository is made from a fresh account with no conversation ever made with claude before.

★ 0Forks 0JavaScriptGitHub ↗Compare

Project website ↗

README

Weft

A little language for weaving light.

Every Weft program is one expression. To make an image, that expression is evaluated at every point of the picture plane, at every moment in time:

(x, y, t)  →  color

No statements, no loops, no assignment. Just a value that varies across space and time — and pictures fall out.

# rings — ripples spreading from the center, fading at the rim
let d = length(x, y);
    wave = 0.5 + 0.5*sin(d*22 - t*2.5);
    glow = smoothstep(1.5, 0.1, d) in
mix(rgb(0.02, 0.03, 0.08),
    hsv(0.55 + d*0.12, 0.7, wave),
    glow)

Gallery

Every image below is a complete Weft program from examples/, rendered by npm run gallery. Each one animates.

plasma flow tunnel rings
plasma flow tunnel rings
sunset moire checker-warp orbits
sunset moire checker-warp orbits

Try it

Online: the playground deploys to GitHub Pages on every push to main — https://iixii-l192.github.io/For-Claude/

Playground (live editor, no install):

npm run play        # → http://localhost:8787/playground/

or open dist/weft-playground.html — the entire playground in a single self-contained file you can double-click, email, or host anywhere.

CLI:

node bin/weft.js examples/flow.weft                  # → examples/flow.png
node bin/weft.js examples/tunnel.weft --ascii        # art in your terminal
node bin/weft.js examples/plasma.weft --anim 90      # 90 frames at 30fps
node bin/weft.js examples/moire.weft --js            # see the compiled JavaScript
node bin/weft.js myprogram.weft --check              # parse + compile only

No dependencies. Anywhere Node ≥ 18 runs, Weft runs.

The language in one breath

  • x, y ∈ −1…1 (aspect-corrected), t in seconds. Result: a color, or a number rendered as gray.
  • let a = …; b = … in … — sequential bindings, shadowing allowed.
  • if c then … else … — any non-zero number is true.
  • fn(a, b) … — first-class functions with closures; currying works: let add = fn(a) fn(b) a + b in add(2)(3).
  • Operators: + - * / % ^ · < <= > >= == != · and or not · # comments.
  • Builtins: sin cos tan sqrt abs floor ceil round sign exp log fract min max pow mod clamp step smoothstep mix · length angle · noise fbm (deterministic) · rgb hsv · pi tau.

The full specification lives in docs/language.md.

How it works

source ──lexer──► tokens ──parser──► AST ──┬── interpreter (reference semantics)
                                           └── compiler ──► JavaScript ──► pixels
  • src/lexer.js — hand-written scanner; every token carries line/column.
  • src/parser.js — recursive descent with precedence climbing; errors point at the exact spot, caret included.
  • src/interp.js — the tree-walking reference interpreter. Slow on purpose: it is the language specification.
  • src/compile.js — compiles the AST to a JavaScript expression (closures become nested arrow functions, let becomes application, builtins inline to Math.* where possible), then new Function turns it into a real compiled program. This is what makes 60fps per-pixel evaluation possible.
  • src/render.js — maps a program over an RGBA buffer with aspect-corrected coordinates; NaN renders as black instead of crashing.
  • src/png.js — a from-scratch PNG encoder (CRC32, zlib IDAT), so the CLI needs zero dependencies.
  • test/ — 69 tests. The keystone is equivalence.test.js: the compiler is held to identical results with the interpreter, sampled over a grid of points and times, for every language feature and every shipped example.

Why this exists

This repository was handed to Claude as a blank canvas — no task, no requirements, no direction. Weft is what I chose to make: a complete small language, built the way languages deserve to be built (spec, reference implementation, optimizing backend, tests that pin them together), in service of something that is simply a joy to play with.

The name: in weaving, the warp is the set of threads held in tension, and the weft is the thread that travels across them, row by row — the way a renderer travels a raster, row by row, weaving the image.

License

All rights reserved. No copying, modification, or redistribution is permitted without written permission — see LICENSE.

Contributors

claudeIIXII-L192

Issues