Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.6 KB

File metadata and controls

56 lines (38 loc) · 1.6 KB

⚡ Trite ⚡

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.

✨ Features

  • 🚀 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.

📦 Installation

Install via npm:

npm install @gotzya/trite

🚀 Quick Start

import { 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();

📖 Documentation

For a full list of classes, methods, and parameters, check out the: 📚 [Detailed API Reference]

🛠️ Development & Tests

To run the local tests, host the project on a local server (e.g., VS Code Live Server) to bypass browser CORS restrictions.

📜 License

This project is licensed under the MIT License.