Monorepo for Aesthetic.Computer
aesthetic.computer
JavaScript API Reference#
Generated from disk.mjs analysis
Overview#
The 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.
API Categories#
🎨 Graphics & Drawing#
Core functions for visual output and screen manipulation.
Screen Management#
wipe(color)- Clear screen with colorresolution(width, height)- Set canvas resolutionscreen- Object containing width/height properties
Drawing Primitives#
ink(color)- Set drawing colorink(r, g, b)- Set RGB colorink(color, alpha)- Set color with transparencyline(x1, y1, x2, y2)- Draw linebox(x, y, w, h, mode?)- Draw rectanglecircle(x, y, radius)- Draw circleplot(x, y)- Set pixeltri(x1, y1, x2, y2, x3, y3)- Draw triangle
Text & Typography#
write(text, x, y, size?)- Draw texttype- Typography utilities and typeface loading
🖱️ Input & Interaction#
Functions for handling user input and events.
Pointer/Mouse#
pointer- Mouse/touch position and statepointer.x, pointer.y- Current coordinatespointer.down, pointer.up- Click states
Keyboard#
keyboard- Keyboard input statekey- Current key being pressed
Touch & Gesture#
- Touch events and multi-touch handling
🔊 Audio & Sound#
Sound generation, playback, and audio processing.
Sound Generation#
tone(frequency, duration)- Generate tonenoise()- Generate noise
Audio Playback#
- Audio file loading and playback
🌐 Networking & Sessions#
Communication and data sharing capabilities.
Socket Communication#
- WebSocket connections for real-time communication
Session Management#
- User sessions and persistence
🔧 Utilities & Math#
Mathematical functions and general utilities.
Math Operations#
- Built-in JavaScript Math functions
- Additional utility functions
Data Structures#
- Array and object manipulation helpers
Usage Patterns#
Basic Piece Structure#
// boot: Initialize piece
function boot({ wipe, screen }) {
// Setup code
}
// paint: Render each frame
function paint({ wipe, ink, box }) {
wipe("black");
ink("white");
box(50, 50, 100, 100);
}
// act: Handle input
function act({ event, pointer }) {
if (event.is("pointer:down")) {
// Handle click
}
}
Common Patterns#
- Screen clearing:
wipe(color) - Setting colors:
ink(color)before drawing - Coordinate systems: (0,0) at top-left
- Event handling: Check
event.is(type)in act function
API Analysis Status#
⚠️ This documentation is under development
- Complete function inventory from disk.mjs
- Parameter types and validation
- Return value documentation
- Usage examples for each function
- Cross-references with pieces that use each function
Next Steps#
- Automated Analysis: Tool to extract all exported functions from disk.mjs
- Type Discovery: Analyze function signatures and parameter types
- Usage Examples: Create working examples for each API function
- Coverage Mapping: Compare with manual documentation in docs.js
- Testing Suite: Validate API documentation against implementation
This is a living document that will be updated as the API analysis tools are developed.