About this project

Litecanvas is a lightweight HTML5 canvas 2D engine aimed at small web games, prototypes, game jams, animations, creative coding and learning game programming. The project is marked as alpha, so breaking changes may occur. Key characteristics described in the README: - Tiny footprint: about 4KB minified and gzipped. - Simple API: a small set of functions for drawing shapes plus utility helpers. - ZzFX integration for playing or creating sound effects. - Extensible through plugins published under the litecanvas keyword. - A web playground for coding and sharing games, usable offline. Getting started options include direct HTML script tags from unpkg or jsDelivr, an ESM template for Node/NPM users, and the browser playground. The engine exposes a litecanvas() entry point that accepts configuration such as width, height and a loop object with init, update and draw callbacks. update and draw are described as running 60 times per second. The API covers: - A default four-color palette addressed by index, customizable via pal(). - Text rendering with text(), including multi-line strings. - Shape drawing: rect, rectfill, circ, circfill, oval and ovalfill. - Sprites defined from strings, where characters map to palette colors and dots are transparent. - Offscreen image creation via paint(), useful as a cache for repeated drawing, plus drawing of loaded PNG/JPG files with image(). - Input handling: iskeydown, iskeypressed and lastkey for keyboard; a tapped callback for clicks and touches; MX and MY variables for mouse position. - Global variables W, H, T, PI and TAU for canvas size, elapsed time and angle constants. A cheatsheet on the project site lists the full API. The repository includes sample demos such as a bouncing ball, a scroller, a 3D projection and a rendering benchmark, with more in the samples folder. An asset loader plugin is recommended for loading multiple images, fonts or audio files. Contributing instructions cover forking and cloning, installing dependencies with npm, formatting, adding tests and running the test suite before opening a pull request. Node.js is required for local development. The README credits inspirations including floppy, PICO-8, js13kGames, raylib, p5.js/Processing and Pygame Zero.