PixelJS - Small Javascript game API

PixelJS Logo
Dependencies Build Release

A small, lightweight Javascript API designed to make drawing on the canvas simpler

Installation

To run PixelJS on your website, add

<script src="https://cdn.jsdelivr.net/gh/ZippyMagician/Pixel/bundles/1.1.0/Pixel.min.js"></script>
<!-- Where "1.1.0" can be subsituted for any version of PixelJS -->

to your website. To install yourself, clone the repo using

git clone https://github.com/ZippyMagician/Pixel

and then run

npm install
npm run build

to generate a file that contains all of Pixel's functions. Use

npm run docs

to create the documentation for Pixel.

Example

Here is an example file you can use in Pixel

var app = new Pixel.Stage({ // Create new Pixel Stage
  height: 400,
  width: 400
});
document.body.appendChild(app.view); // Add stage to document body

var rect = new Pixel.Rectangle(100, 100); // Create new rectangle with width and height of 100

rect.x = 200;
rect.y = 200;
rect.setAnchor(0.5, 0.5); // Center rectangle, move to center of screen

app.addChild(rect); // Add rectangle to screen

app.stage.on('tick', () => {
  rect.deg += 5; // Every tick, rotate 5 degrees
});