0.0.6 • Published 4 years ago

@mystroken/canvas v0.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

Canvas

contributions welcome

:kiwi_fruit: Object oriented canvas 2D rendering in JavaScript.

Installation

npm install @mystroken/canvas

Usage

Look at the sources files for more information.

Import
import Canvas from '@mystroken/canvas';
import Renderable from '@mystroken/canvas/Renderable'; 
Create a renderable.
class Circle extends Renderable {

    render(ctx) {
        ctx.beginPath();
        ctx.arc(110, 110, 25, Math.PI * 2, false);
        ctx.closePath();

        ctx.stroke();
    }
}
Add renderables on the canvas.
const canvas = new Canvas(document.querySelector('#canvas'));

// Get some renderables.
const circle = new Circle();
const rect = new Rectangle();

// Adds renderables to canvas.
canvas.add(circle);
canvas.add(rect);

// Render the canvas.
canvas.render();
0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago