Monorepo for Aesthetic.Computer
aesthetic.computer
1# JavaScript API Reference
2
3*Generated from disk.mjs analysis*
4
5## Overview
6
7The Aesthetic Computer JavaScript API is provided through `disk.mjs` and serves as the primary interface for creating interactive pieces. This API provides graphics, input, audio, networking, and utility functions.
8
9## API Categories
10
11### 🎨 Graphics & Drawing
12Core functions for visual output and screen manipulation.
13
14#### Screen Management
15- `wipe(color)` - Clear screen with color
16- `resolution(width, height)` - Set canvas resolution
17- `screen` - Object containing width/height properties
18
19#### Drawing Primitives
20- `ink(color)` - Set drawing color
21- `ink(r, g, b)` - Set RGB color
22- `ink(color, alpha)` - Set color with transparency
23- `line(x1, y1, x2, y2)` - Draw line
24- `box(x, y, w, h, mode?)` - Draw rectangle
25- `circle(x, y, radius)` - Draw circle
26- `plot(x, y)` - Set pixel
27- `tri(x1, y1, x2, y2, x3, y3)` - Draw triangle
28
29#### Text & Typography
30- `write(text, x, y, size?)` - Draw text
31- `type` - Typography utilities and typeface loading
32
33### 🖱️ Input & Interaction
34Functions for handling user input and events.
35
36#### Pointer/Mouse
37- `pointer` - Mouse/touch position and state
38- `pointer.x, pointer.y` - Current coordinates
39- `pointer.down, pointer.up` - Click states
40
41#### Keyboard
42- `keyboard` - Keyboard input state
43- `key` - Current key being pressed
44
45#### Touch & Gesture
46- Touch events and multi-touch handling
47
48### 🔊 Audio & Sound
49Sound generation, playback, and audio processing.
50
51#### Sound Generation
52- `tone(frequency, duration)` - Generate tone
53- `noise()` - Generate noise
54
55#### Audio Playback
56- Audio file loading and playback
57
58### 🌐 Networking & Sessions
59Communication and data sharing capabilities.
60
61#### Socket Communication
62- WebSocket connections for real-time communication
63
64#### Session Management
65- User sessions and persistence
66
67### 🔧 Utilities & Math
68Mathematical functions and general utilities.
69
70#### Math Operations
71- Built-in JavaScript Math functions
72- Additional utility functions
73
74#### Data Structures
75- Array and object manipulation helpers
76
77## Usage Patterns
78
79### Basic Piece Structure
80```javascript
81// boot: Initialize piece
82function boot({ wipe, screen }) {
83 // Setup code
84}
85
86// paint: Render each frame
87function paint({ wipe, ink, box }) {
88 wipe("black");
89 ink("white");
90 box(50, 50, 100, 100);
91}
92
93// act: Handle input
94function act({ event, pointer }) {
95 if (event.is("pointer:down")) {
96 // Handle click
97 }
98}
99```
100
101### Common Patterns
102- Screen clearing: `wipe(color)`
103- Setting colors: `ink(color)` before drawing
104- Coordinate systems: (0,0) at top-left
105- Event handling: Check `event.is(type)` in act function
106
107## API Analysis Status
108
109**⚠️ This documentation is under development**
110
111- [ ] Complete function inventory from disk.mjs
112- [ ] Parameter types and validation
113- [ ] Return value documentation
114- [ ] Usage examples for each function
115- [ ] Cross-references with pieces that use each function
116
117## Next Steps
118
1191. **Automated Analysis**: Tool to extract all exported functions from disk.mjs
1202. **Type Discovery**: Analyze function signatures and parameter types
1213. **Usage Examples**: Create working examples for each API function
1224. **Coverage Mapping**: Compare with manual documentation in docs.js
1235. **Testing Suite**: Validate API documentation against implementation
124
125---
126
127*This is a living document that will be updated as the API analysis tools are developed.*