5.0.5 • Published 1 year ago

yy-rendersheet v5.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

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

5.0.5

1 year ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.7.2

3 years ago

3.7.1

3 years ago

3.7.0

3 years ago

3.6.3

3 years ago

3.6.2

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.3

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

1.3.3

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago