Constructor
new TextureSheet(sizeopt)
Create a texture sheet, called automatically by loadSprite
| Name | Type | Attributes | Description |
|---|---|---|---|
size | number | <optional> | Width and height of the sheet in pixels |
- Source
Members
canvas
Properties| Type | Description |
|---|---|
| OffscreenCanvas | Canvas holding the packed images |
- Source
context
Properties| Type | Description |
|---|---|
| OffscreenCanvasRenderingContext2D | 2d context for the canvas |
- Source
cursor
Properties| Type | Description |
|---|---|
| Vector2 | Where the next image will be packed |
- Source
glDirty
Properties| Type | Description |
|---|---|
| boolean | Has the canvas changed since the last webgl upload? |
- Source
rowHeight
Properties| Type | Description |
|---|---|
| number | Height of the row being packed |
- Source
size
Properties| Type | Description |
|---|---|
| number | Width and height of the sheet in pixels |
- Source
textureInfo
Properties| Type | Description |
|---|---|
| TextureInfo | The texture info for this sheet |
- Source
Methods
drawImage(image, tileInfo, updateopt, sourcePaddingopt)
Draw an image into this sheet at a tile returned by tryAdd
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
image | HTMLImageElement | Source image to copy from | ||
tileInfo | TileInfo | Where to put it, from tryAdd | ||
update | boolean | <optional> | true | Upload to webgl now, pass false when batching |
sourcePadding | number | | <optional> | 0 | How many pixels padding around each frame in the source image |
- Source
tryAdd(imageSize, frameSizeopt, paddingopt, sourcePaddingopt) → {TileInfo}
Find a spot for an image on this sheet without drawing it
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
imageSize | Vector2 | Size of the source image in pixels | ||
frameSize | Vector2 | <optional> | Size of each frame, or the whole image if not passed | |
padding | number | <optional> | How many pixels padding around each frame | |
sourcePadding | number | | <optional> | 0 | How many pixels padding around each frame in the source image |
- Source
Tile for the packed image, or undefined if the sheet is full
- Type:
- TileInfo
updateTexture()
Upload the canvas to webgl if it has changed since the last upload Only needed after batching, drawImage uploads automatically by default
- Source