Trite is a lightweight, high-performance 2D graphics library for the web. While it uses the familiar HTML5 Canvas API for setup, all rendering is powered by WebGL2 for maximum speed through batched draw calls.
- 🚀 WebGL2 Powered: Hardware-accelerated rendering for smooth performance.
- 📦 Batched Rendering: Automatically group similar shapes into single draw calls.
- 🎨 Simple Primitives: Easily draw Circles, Triangles, Rectangles, and Lines.
- 🔄 Reusable Arrays: Optimized memory management for dynamic scenes.
- Modern Syntax: Full JSDoc support for excellent IDE autocomplete.
Install via npm:
npm install @gotzya/triteimport { Render, Rectangle } from "@gotzya/trite";
const canvas = document.getElementById("canvas");
const render = new Render(canvas);
// Clear the screen
render.setClearColor(23, 23, 23);
render.clear();
// Draw a simple rectangle
const rect = new Rectangle(50, 50, 100, 100);
rect.setColor(27, 208, 178);
rect.draw();
// Batched rendering (High Performance)
const batch = new Rectangle();
batch.add(200, 50, 50, 50, 237, 134, 55);
batch.add(300, 50, 50, 50, 237, 134, 55);
batch.draw();For a full list of classes, methods, and parameters, check out the: 📚 [Detailed API Reference]
To run the local tests, host the project on a local server (e.g., VS Code Live Server) to bypass browser CORS restrictions.
This project is licensed under the MIT License.