How a program works
- The editor holds a Python module. Every
@kernelfunction becomes a WebGPU compute shader. Run (Ctrl/Cmd+Enter) compiles it; Auto does the same about 0.7 s after you stop typing. A failed compile keeps the last good program running and marks the line. - The grid is W cells across, set by Grid. H follows the shape of the canvas, at most 2048. Each kernel runs once per cell:
gid % wis the column andgid // wthe row. - Every
list[float]parameter, in any kernel, is one W×H buffer shared by that name. Reset zeroes them. - Declare
wandhasint,tasfloat(seconds since reset),frameasint,mxandmyasfloat(pointer in cells, -1 outside the canvas) andmdownasint(1 while pressed or touching). The playground fills them in. Any other scalar becomes a slider. # slider NAME MIN MAX DEFAULTsets a slider's range. Without it a float slider runs 0 to 1 at 0.5 and an int slider 0 to 100 at 10.# steps Nruns the per-frame kernels N times a frame.# display LO HImaps values linearly;# display cyclic FREQwraps value × FREQ around the palette. The default is# display 0 1.initruns once after each reset. Every other kernel runs every frame, in source order. The picture showsoutif there is one, otherwise the last buffer the last kernel writes.- Pause stops the kernels and freezes
tandframe. Sliders apply from the next frame; a value that onlyinitreads applies on Reset. - Supported: arithmetic, comparisons,
if,while,for … in range(),break,continue, andmin max abs floor sqrt exp log powwithsin cos tan atan2. There is no**; writex*x.
Unlike the demos, nothing here compares the GPU result with CPython. The compiler is the same one, ported to JavaScript and held to the Python version by a test suite. In the editor, Tab indents, Shift+Tab dedents and Esc leaves the editor.