Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 41 lines 1.3 kB view raw
1// Resource: aesthetic-computer://piece-template 2// Starter template for a new aesthetic.computer piece 3 4export const pieceTemplateResource = { 5 uri: "aesthetic-computer://piece-template", 6 name: "Aesthetic Computer Piece Template", 7 description: "A starter template for creating a new aesthetic.computer piece with all lifecycle functions", 8 mimeType: "text/javascript", 9}; 10 11export function getPieceTemplate() { 12 return `// my-piece, ${new Date().getFullYear()}.${String(new Date().getMonth() + 1).padStart(2, '0')}.${String(new Date().getDate()).padStart(2, '0')} 13// A short description of this piece. 14 15// \`boot\` runs once at startup. 16export function boot($) { 17 // Initialize state here. 18 // $.screen.width, $.screen.height for dimensions. 19} 20 21// \`sim\` runs every logic tick (before paint). 22export function sim($) { 23 // Update simulation / physics / state. 24} 25 26// \`paint\` runs every frame for rendering. 27export function paint($) { 28 const { wipe, ink, line, box, circle, pixel, screen } = $; 29 wipe("black"); // Clear screen. 30 ink("red"); // Set draw color. 31 box(10, 10, 50, 50); // Draw a filled rect. 32} 33 34// \`act\` runs on user input events. 35export function act($) { 36 const { event: e } = $; 37 // e.is("touch"), e.is("draw"), e.is("lift") 38 // e.x, e.y for coordinates 39} 40`; 41}