Class: RenderSheet

RenderSheet

new RenderSheet (options)

Name Type Description
options object
Name Type Default Description
maxSize number 2048 optional
buffer number 5 optional

around each texture

scale number 1 optional

of texture

resolution number 1 optional

of rendersheet

extrude number optional

the edges--useful for removing gaps in sprites when tiling

wait number 250 optional

number of milliseconds to wait between checks for onload of addImage images before rendering

testBoxes boolean optional

draw a different colored boxes behind each rendering (useful for debugging)

scaleMode number | boolean optional

PIXI.settings.SCALE_MODE to set for rendersheet (use =true for PIXI.SCALE_MODES.NEAREST for pixel art)

useSimplePacker boolean optional

use a stupidly simple packer instead of growing packer algorithm

show boolean | object optional

set to true or a CSS object (e.g., {zIndex: 10, background: 'blue'}) to attach the final canvas to document.body--useful for debugging

Methods

add (name, draw, measure, params)object

adds a canvas rendering

Name Type Description
name string

of rendering

draw function

function(context) - use the context to draw within the bounds of the measure function

measure function

function(context) - needs to return {width: width, height: height} for the rendering

params object

object to pass the draw() and measure() functions

Returns:
Type Description
object rendersheet object for texture

addData (data, header)object

adds a data source (e.g., a PNG file in data format)

Name Type Default Description
data object

of rendering (not filename)

header string data:image/png;base64, optional

for data

Returns:
Type Description
object rendersheet object for texture

addImage (name, src)object

adds an image rendering

Name Type Description
name string

of rendering

src string

for image

Returns:
Type Description
object rendersheet object for texture

asyncRender (skipTextures)

create (or refresh) the rendersheet (supports async instead of callback)

Name Type Description
skipTextures boolean

don't create PIXI.BaseTextures and PIXI.Textures (useful for generating external spritesheets)

changeDraw (name, draw)

Changes the drawing function of a texture NOTE: this only works if the texture remains the same size; use Sheet.render() to resize the texture

Name Type Description
name string
draw function

checkLoaded ()boolean

checks if all textures are loaded

Returns:
Type Description
boolean

removes all textures from rendersheets

prints statistics of canvases to console.log

entries ()number

Returns:
Type Description
number amount of textures in this rendersheet

exists (name)boolean

tests whether a texture exists

Name Type Description
name string

of texture

Returns:
Type Description
boolean

get (name)PIXI.Sprite

alias for getSprite()

Name Type Description
name string

of texture

Returns:
Type Description
PIXI.Sprite

getIndex (find)PIXI.Texture

find the index of the texture based on the texture object

Name Type Description
find number

this indexed texture

Returns:
Type Description
PIXI.Texture

getSprite (name)PIXI.Sprite

returns a PIXI.Sprite (with anchor set to 0.5, because that's where it should be)

Name Type Description
name string

of texture

Returns:
Type Description
PIXI.Sprite

getTexture (name)PIXI.Texture | null

Name Type Description
name string

of texture

Returns:
Type Description
PIXI.Texture | null

render (skipTextures, callback)

create (or refresh) the rendersheet

Name Type Description
skipTextures boolean

don't create PIXI.BaseTextures and PIXI.Textures (useful for generating external spritesheets)

callback function

convenience function that calls RenderSheet.once('render', callback)

Events

fires when render completes