GCANVAS

A modular 2D canvas rendering and game framework

View on GitHub →

Quick Start

GCanvas provides a clean, object-oriented API for building canvas-based games and visualizations. Get started in minutes with a simple example:

import { Game, Rectangle, Circle } from '@guinetik/gcanvas';

const canvas = document.getElementById('my-canvas');
const game = new Game(canvas);
game.backgroundColor = '#000';
game.enableFluidSize();

game.init();

// Create shapes
const rect = new Rectangle({
  x: 200,
  y: 150,
  width: 100,
  height: 50,
  color: '#1a1a1a',
  stroke: '#0f0',
  lineWidth: 1
});

const circle = new Circle(30, {
  x: 300,
  y: 150,
  color: '#2a2a2a',
  stroke: '#0f0',
  lineWidth: 1
});

// Add to pipeline
game.pipeline.add(rect);
game.pipeline.add(circle);

game.start();

Key Features

Two Ways to Use

1. Object-Oriented API

Full control with classes and explicit game loop management. Perfect for complex games and applications.

import { Game, Scene, GameObject } from '@guinetik/gcanvas';

class MyGame extends Game {
  init() {
    const scene = new Scene(this);
    // Add your game objects
    this.pipeline.add(scene);
  }
}

2. Fluent API

Declarative, chainable API for rapid development. Great for prototypes, creative coding, and simple games.

import { gcanvas } from '@guinetik/gcanvas';

gcanvas({ bg: '#000' })
  .scene('game')
    .go({ x: 200, y: 150 })
      .circle({ radius: 30, fill: '#1a1a1a', stroke: '#0f0' })
      .pulse({ min: 0.8, max: 1.2, duration: 1 })
  .start();

Explore the Demos

Check out these examples to see GCanvas in action. Each demo showcases different aspects of the framework.

Installation

npm install @guinetik/gcanvas

ES Modules

import { Game, Circle, Rectangle } from '@guinetik/gcanvas';

CDN

<script type="module">
  import { Game } from 'https://cdn.jsdelivr.net/npm/gcanvas/dist/gcanvas.es.min.js';
</script>

Documentation

For complete API documentation, visit the documentation pages in the navigation menu. Each demo includes source code and explanations.