canvas-cake
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Canvas Cake

NPM Package NPM Package NPM Package

CAKES! Everybody loves cakes! Cakes have layers!

-Donkey

This is a simple package to help use layers on the canvas. It simply gives helper classes to add, remove, and move layers around.

Examples

// Basic setup
import Cake from "canvas-cake";

const cake = new Cake(canvas);

const l1 = cake.newLayer();
const l1_ctx = l1.getContext();
l1_ctx.fillRect(0, 0, 50, 50);

const l2 = cake.newLayer(10, 10);
const l2_ctx = l2.getContext();
l2_ctx.fillStyle = "#00aaff";
l2_ctx.fillRect(0, 0, 50, 50);

cake.update();

example1

// Move layer z-index
import Cake from "canvas-cake";

const cake = new Cake(canvas);

const l1 = cake.newLayer();
const l1_ctx = l1.getContext();
l1_ctx.fillRect(0, 0, 50, 50);

const l2 = cake.newLayer(10, 10);
const l2_ctx = l2.getContext();
l2_ctx.fillStyle = "#00aaff";
l2_ctx.fillRect(0, 0, 50, 50);

cake.setLayerZIndex(l2, 0);

cake.update();

example1

Package Sidebar

Install

npm i canvas-cake

Weekly Downloads

0

Version

1.0.2

License

gpl-3.0

Unpacked Size

40.1 kB

Total Files

5

Last publish

Collaborators

  • aspymui