yy-rendersheet

5.0.5 • Public • Published

rendersheet.js

Generate on-the-fly spritesheets for pixi.js

Rationale

I needed a way to generate spritesheets based on canvas drawings and/or images. This allows me to resize the drawings based on different resolutions. For canvas drawings, you pass the rendersheet two functions: a drawing function and a measure function.

Code Example

// set up rendersheet
var sheet = new RenderSheet();

// draw triangle textures on rendersheet
sheet.add('triangle', triangleDraw, triangleMeasure, {size: 50, 'red'});

// image texture on rendersheet
sheet.addImage('image', 'images/test.png');

// render the sheet
sheet.render();

// create a PIXI.Sprite using the rendersheet
var sprite = stage.addChild(sheet.get('triangle'));

// use a PIXI.Texture from the rendershet
var image = stage.addChild(new PIXI.Sprite(sheet.getTexture('image')));

// drawing function to generate the canvas triangle
function triangleDraw(c, params)
{
    var size = params.size;
    var half = params.size / 2;
    c.beginPath();
    c.fillStyle = params.color;
    c.moveTo(half, 0);
    c.lineTo(0, size);
    c.lineTo(size, size);
    c.closePath();
    c.fill();
}

// measure function to provide dimensions for canvas triangle
function triangleMeasure(c, params)
{
    return { width: params.size, height: params.size };
}

Installation

npm i yy-rendersheet

Live Example

https://davidfig.github.io/rendersheet/

API Documentation

https://davidfig.github.io/rendersheet/jsdoc

license

MIT License
(c) 2019 YOPEY YOPEY LLC by David Figatner

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.53latest

Version History

VersionDownloads (Last 7 Days)Published
5.0.53
5.0.40
5.0.32
5.0.20
5.0.10
5.0.00
4.2.31
4.2.20
4.2.10
4.2.00
4.1.10
4.1.00
4.0.20
4.0.10
4.0.00
3.7.20
3.7.10
3.7.00
3.6.30
3.6.20
3.6.10
3.6.00
3.5.10
3.5.00
3.4.00
3.3.20
3.3.10
3.3.00
3.2.30
3.2.20
3.2.10
3.2.00
3.1.00
3.0.10
3.0.00
1.3.30
1.3.20
1.3.10
1.3.00
1.2.20
1.2.10
1.2.00
1.1.20
1.1.10
1.1.00
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i yy-rendersheet

Weekly Downloads

4

Version

5.0.5

License

MIT

Unpacked Size

3.53 MB

Total Files

59

Last publish

Collaborators

  • davidfig