Monorepo for Aesthetic.Computer aesthetic.computer
at main 261 lines 10 kB view raw view rendered
1# 🎯 KidLisp Complete API Reference Map 2 3Generated from `kidlisp.mjs` on 2025-10-17 4 5## 💬 String Literals 6 7Both **double quotes** and **single quotes** work for string literals: 8- `"text"` - Double quotes (traditional) 9- `'text'` - Single quotes (new!) 10- Example: `(write "hello" x y)` or `(write 'hello' x y)` 11- Useful for avoiding escaping when mixing quote types 12- Works everywhere: colors, text, mode parameters, etc. 13 14## 📖 Core System Functions 15 16### **Language & Control Flow** 17| Function | Usage | Description | 18|----------|-------|-------------| 19| `def` | `(def name value)` | Define variables | 20| `later` | `(later name params body)` | Define functions | 21| `if` | `(if condition then else)` | Conditional execution | 22| `once` | `(once expr)` | Execute only once per session | 23| `not` | `(not expr)` | Logical negation | 24| `now` | `(now)` | Execute immediately | 25| `die` | `(die)` | Stop execution | 26 27### **Math & Numbers** 28| Function | Usage | Description | 29|----------|-------|-------------| 30| `+` | `(+ a b c...)` | Addition | 31| `-` | `(- a b)` | Subtraction | 32| `*` | `(* a b c...)` | Multiplication | 33| `/` | `(/ a b)` | Division | 34| `%` | `(% a b)` | Modulo | 35| `sin` | `(sin x)` | Sine function | 36| `cos` | `(cos x)` | Cosine function | 37| `max` | `(max a b c...)` | Maximum value | 38| `min` | `(min a b c...)` | Minimum value | 39| `mod` | `(mod a b)` | Modulo operation | 40| `mul` | `(mul a b c...)` | Multiplication (alias) | 41| `random` | `(random max)` | Random number 0 to max | 42| `range` | `(range start end)` | Create number range | 43| `wiggle` | `(wiggle amount)` | Random ±amount/2 | 44 45## 🎨 Graphics & Drawing 46 47### **Screen Management** 48| Function | Usage | Description | 49|----------|-------|-------------| 50| `resolution` | `(resolution w h)` | Set canvas resolution | 51| `wipe` | `(wipe color)` | Clear screen with color | 52| `coat` | `(coat color alpha)` | Semi-transparent overlay | 53| `mask` | `(mask x y w h)` | Set drawing mask region | 54| `unmask` | `(unmask)` | Remove drawing mask | 55 56### **Drawing Primitives** 57| Function | Usage | Description | 58|----------|-------|-------------| 59| `ink` | `(ink color)` | Set drawing color | 60| `line` | `(line x1 y1 x2 y2)` | Draw line | 61| `lines` | `(lines points...)` | Draw connected lines | 62| `box` | `(box x y w h)` | Draw rectangle (respects fill/outline mode) | 63| `box` | `(box x y w h "fill")` | Explicitly filled rectangle | 64| `box` | `(box x y w h "outline")` | Explicitly outlined rectangle | 65| `circle` | `(circle x y radius)` | Draw circle (respects fill/outline mode) | 66| `circle` | `(circle x y r "fill")` | Explicitly filled circle | 67| `circle` | `(circle x y r "outline")` | Explicitly outlined circle | 68| `circle` | `(circle x y r "outline:N")` | Outlined circle with thickness N | 69| `tri` | `(tri x1 y1 x2 y2 x3 y3)` | Draw triangle (respects fill/outline mode) | 70| `tri` | `(tri ... "fill")` | Explicitly filled triangle | 71| `tri` | `(tri ... "outline")` | Explicitly outlined triangle | 72| `plot` | `(plot x y)` | Draw single pixel | 73| `flood` | `(flood x y color)` | Flood fill area | 74| `shape` | `(shape points filled)` | Draw custom polygon | 75 76### **Fill/Outline Modes** 🆕 77| Function | Usage | Description | 78|----------|-------|-------------| 79| `fill` | `(fill)` | Set global fill mode for all shapes (default) | 80| `outline` | `(outline)` | Set global outline mode | 81| `stroke` | `(stroke)` | Alias for outline (Processing) | 82| `nofill` | `(nofill)` | Alias for outline (Processing) | 83| `nostroke` | `(nostroke)` | Alias for fill (Processing) | 84 85**Examples:** 86```lisp 87; Default is fill mode (matches box's default) 88(circle 100 100 50) ; Filled 89(box 50 50 40 40) ; Also filled 90 91(outline) 92(circle 200 100 50) ; Outline 93 94; Explicit mode overrides global 95(fill) 96(circle 100 100 50) ; Filled (global) 97(circle 200 100 50 "outline") ; Override to outline 98(circle 300 100 50) ; Filled (back to global) 99``` 100 101### **Color & Effects** 102| Function | Usage | Description | 103|----------|-------|-------------| 104| `fade` | `(fade "red-blue" direction)` | Color gradients | 105| `rainbow` | `(rainbow)` | Cycling rainbow colors | 106| `zebra` | `(zebra)` | Black/white alternating | 107| `backdrop` | `(backdrop color)` | Set background color | 108 109## 🖼️ Images & Media 110 111### **Image Functions** 112| Function | Usage | Description | 113|----------|-------|-------------| 114| `paste` | `(paste url x y scale)` | Paste image at position | 115| `stamp` | `(stamp url x y)` | Paste image centered | 116| `painting` | `(painting x y)` | Paste current user's painting | 117| `steal` | `(steal)` | Copy current buffer | 118| `putback` | `(putback)` | Restore copied buffer | 119 120### **Text Rendering** 121| Function | Usage | Description | 122|----------|-------|-------------| 123| `write` | `(write text x y bg size)` | Draw text | 124| `len` | `(len text)` | Get text length | 125 126## 🔄 Transformations & Effects 127 128### **Pixel Transformations** 129| Function | Usage | Description | 130|----------|-------|-------------| 131| `scroll` | `(scroll dx dy)` | Scroll canvas pixels | [📖](docs/functions/scroll.md) | 132| `zoom` | `(zoom factor centerX centerY)` | Zoom in/out from center | [📖](docs/functions/zoom.md) | 133| `suck` | `(suck strength centerX centerY)` | Radial displacement (vortex) | [📖](docs/functions/suck.md) | 134| `spin` | `(spin angle)` | Rotate canvas | [📖](docs/functions/spin.md) | 135| `resetSpin` | `(resetSpin)` | Reset rotation | 136| `smoothspin` | `(smoothspin angle)` | Smooth rotation | 137| `sort` | `(sort)` | Sort pixels by brightness | 138| `blur` | `(blur amount)` | Blur entire canvas | 139| `contrast` | `(contrast amount)` | Adjust contrast | 140| `pan` | `(pan dx dy)` | Pan camera view | 141| `unpan` | `(unpan)` | Reset camera position | 142 143## 🎵 Audio & Sound 144 145### **Audio Input** 146| Function | Usage | Description | 147|----------|-------|-------------| 148| `mic` | `(mic)` | Access microphone | 149| `amplitude` | `(amplitude)` | Get audio amplitude | 150| `speaker` | `(speaker)` | Audio output control | 151 152### **Music Generation** 153| Function | Usage | Description | 154|----------|-------|-------------| 155| `melody` | `(melody notes)` | Play musical sequence | 156| `overtone` | `(overtone freq)` | Generate harmonic tones | 157| `noise` | `(noise)` | Generate noise | 158 159## 🎮 3D Graphics 160 161### **3D Objects** 162| Function | Usage | Description | 163|----------|-------|-------------| 164| `cube` | `(cube id)` | Create/reference cube | 165| `quad` | `(quad)` | Create quad primitive | 166| `form` | `(form objects...)` | Render 3D forms | 167| `trans` | `(trans form transformations...)` | Transform 3D objects | 168 169### **3D Transformations** 170| Function | Usage | Description | 171|----------|-------|-------------| 172| `cubespin` | `(cubespin x y z)` | Animate cube rotation | 173| `cubepos` | `(cubepos x y z)` | Set cube position | 174| `cubescale` | `(cubescale factor)` | Scale cube | 175| `cuberot` | `(cuberot x y z)` | Set cube rotation | 176 177### **Camera Control** 178| Function | Usage | Description | 179|----------|-------|-------------| 180| `camrot` | `(camrot x y z)` | Set camera rotation | 181| `camrotx` | `(camrotx angle)` | Rotate camera X | 182| `camroty` | `(camroty angle)` | Rotate camera Y | 183| `camrotz` | `(camrotz angle)` | Rotate camera Z | 184| `camspin` | `(camspin x y z)` | Animate camera rotation | 185| `camspinx` | `(camspinx speed)` | Animate camera X rotation | 186| `camspiny` | `(camspiny speed)` | Animate camera Y rotation | 187| `camspinz` | `(camspinz speed)` | Animate camera Z rotation | 188 189## 📊 Data & Values 190 191### **System Properties** 192| Function | Usage | Description | 193|----------|-------|-------------| 194| `width` / `w` | `(width)` | Canvas width | 195| `height` / `h` | `(height)` | Canvas height | 196| `frame` / `f` | `(frame)` | Current frame number | 197| `clock` | `(clock)` | UTC timestamp | 198| `fps` | `(fps rate)` | Set/get frame rate | 199 200### **Data Manipulation** 201| Function | Usage | Description | 202|----------|-------|-------------| 203| `repeat` / `rep` | `(repeat count expr)` | Repeat expression | 204| `choose` | `(choose options...)` | Random selection | 205| `source` | `(source code)` | Access AST source | 206| `cache` | `(cache id)` | Store/retrieve data | 207 208## 🔧 Utility Functions 209 210### **Control & Logic** 211| Function | Usage | Description | 212|----------|-------|-------------| 213| `tap` | `(tap)` | Handle touch/click | 214| `draw` | `(draw)` | Force redraw | 215| `hop` | `(hop url)` | Navigate to URL | 216| `delay` | `(delay time expr)` | Delayed execution | 217| `debug` | `(debug value)` | Debug logging | 218| `log` | `(log message)` | Console logging | 219| `label` | `(label text color offset)` | HUD label | 220 221### **Boolean Values** 222| Function | Usage | Description | 223|----------|-------|-------------| 224| `yes` | `(yes)` | Boolean true | 225| `no` | `(no)` | Boolean false | 226 227### **Advanced Features** 228| Function | Usage | Description | 229|----------|-------|-------------| 230| `embed` | `(embed code args...)` | Execute embedded code | 231| `bake` | `(bake)` | Finalize current frame | 232| `jump` | `(jump piece)` | Navigate to piece | 233 234## 🎨 Color Shortcuts 235 236All CSS color names are available as functions: 237- `red`, `blue`, `green`, `yellow`, `orange`, `purple`, `magenta` 238- `cyan`, `teal`, `lime`, `gray`, `grey`, `white`, `black` 239- Plus many more CSS colors 240 241## 🌪️ Transformation Functions 242 243KidLisp provides 11 transformation functions for pixel manipulation, each with equal importance: 244 245```lisp 246(scroll 5 0) ; Translation with wrapping 247(zoom 1.1) ; Scale from center point 248(spin 1) ; Rotation around center 249(suck 0.5) ; Radial displacement 250(blur 2) ; Gaussian blur effect 251``` 252 253All transformation functions follow similar patterns: 254- **Accumulation systems** for continuous evolution 255- **Deferred execution** compatible with embedded layers 256- **Performance optimization** for real-time use 257- **Composability** for layered effects 258 259--- 260 261*This API map represents the complete KidLisp function set as of September 2025. Functions are dynamically resolved from global environment, API context, and user definitions.*