1681-engine / index / CanvasTexture
Class: CanvasTexture ​
Defined in: src/core/TextureRegistry.ts:28
A canvas-backed texture with named frames; repaint the canvas, then refresh() to upload it. Made with a view, it is one rect of another texture's canvas on that texture's own source (TextureRegistry.addView): small pieces swapped every few frames then batch together, where a source each made Pixi rebuild its draw instructions at every swap.
Constructors ​
Constructor ​
new CanvasTexture(
key,
canvas,
view?
): CanvasTexture;Defined in: src/core/TextureRegistry.ts:34
Parameters ​
| Parameter | Type |
|---|---|
key | string |
canvas | HTMLCanvasElement |
view? | { frame: Rectangle; source: CanvasSource; } |
view.frame? | Rectangle |
view.source? | CanvasSource |
Returns ​
CanvasTexture
Properties ​
canvas ​
readonly canvas: HTMLCanvasElement;Defined in: src/core/TextureRegistry.ts:36
frames ​
readonly frames: Map<string, Texture<TextureSource<any>>>;Defined in: src/core/TextureRegistry.ts:29
key ​
readonly key: string;Defined in: src/core/TextureRegistry.ts:35
source ​
readonly source: CanvasSource;Defined in: src/core/TextureRegistry.ts:30
whole ​
readonly whole: Texture;Defined in: src/core/TextureRegistry.ts:31
Accessors ​
context ​
Get Signature ​
get context(): CanvasRenderingContext2D;Defined in: src/core/TextureRegistry.ts:52
Returns ​
CanvasRenderingContext2D
height ​
Get Signature ​
get height(): number;Defined in: src/core/TextureRegistry.ts:48
Returns ​
number
width ​
Get Signature ​
get width(): number;Defined in: src/core/TextureRegistry.ts:44
Returns ​
number
Methods ​
add() ​
add(
name,
_source,
x,
y,
w,
h
): void;Defined in: src/core/TextureRegistry.ts:57
Adds a frame cut from the canvas (_source kept for the old call shape).
Parameters ​
| Parameter | Type |
|---|---|
name | string |
_source | number |
x | number |
y | number |
w | number |
h | number |
Returns ​
void
addPacked() ​
addPacked(frame, page?): void;Defined in: src/core/TextureRegistry.ts:66
Adds a packed frame cut from page (this texture's canvas by default): trimmed frames keep their untrimmed size (orig) so they line up when drawn, and frames the packer turned are turned back (Pixi's rotate: 2).
Parameters ​
| Parameter | Type |
|---|---|
frame | PackedFrame |
page | CanvasTexture |
Returns ​
void
adopt() ​
adopt(name, from): void;Defined in: src/core/TextureRegistry.ts:83
Registers under this texture a frame that lives on another one (an atlas page after the first), so the frame is found by this texture's key. A texture of its own over the other page's source: each side frees its own.
Parameters ​
| Parameter | Type |
|---|---|
name | string |
from | CanvasTexture |
Returns ​
void
destroy() ​
destroy(): void;Defined in: src/core/TextureRegistry.ts:94
Returns ​
void
refresh() ​
refresh(): void;Defined in: src/core/TextureRegistry.ts:90
Returns ​
void