5.0.5 • Published 4 years ago

yy-rendersheet v5.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years 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

4 years ago

5.0.4

5 years ago

5.0.3

5 years ago

5.0.2

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.2.3

5 years ago

4.2.2

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.7.2

6 years ago

3.7.1

6 years ago

3.7.0

6 years ago

3.6.3

6 years ago

3.6.2

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.0

6 years ago

3.3.2

6 years ago

3.3.1

6 years ago

3.3.0

6 years ago

3.2.3

6 years ago

3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago