Constructor
new CanvasLayer(posopt, sizeopt, angleopt, renderOrderopt, canvasSizeopt, useWebGLopt)
Create a canvas layer object
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | <optional> | World space position of the layer | |
size | Vector2 | <optional> | World space size of the layer | |
angle | number | <optional> | 0 | Angle the layer is rotated by |
renderOrder | number | <optional> | 0 | Objects sorted by renderOrder |
canvasSize | Vector2 | <optional> | Default size of canvas, can be changed later | |
useWebGL | boolean | <optional> | true | Should this layer use WebGL for rendering |
- Source
const canvasLayer = new CanvasLayer(vec2(), vec2(200,100));Extends
- EngineObject
Members
canvas
Properties| Type | Description |
|---|---|
| OffscreenCanvas | The canvas used by this layer |
- Source
context
Properties| Type | Description |
|---|---|
| OffscreenCanvasRenderingContext2D | The 2D canvas context used by this layer |
- Source
textureInfo
Properties| Type | Description |
|---|---|
| TextureInfo | Texture info to use for this object rendering |
- Source
Methods
destroy(immediateopt)
Destroy this canvas layer
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
immediate | boolean | <optional> | false | Remove it now, as EngineObject.destroy does, children included |
- Source
draw(pos, sizeopt, coloropt, angleopt, mirroropt, additiveColoropt, screenSpaceopt, contextopt)
Draw this canvas layer centered in world space
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | Center in world space | ||
size | Vector2 | <optional> | Size in world space | |
color | Color | <optional> | Color to modulate with | |
angle | number | <optional> | 0 | Angle to rotate by |
mirror | boolean | <optional> | false | If true image is flipped along the Y axis |
additiveColor | Color | <optional> | Additive color to be applied if any | |
screenSpace | boolean | <optional> | drawScreenSpace | If true the pos and size are in screen space |
context | CanvasRenderingContext2D | | <optional> | Canvas 2D context to draw to |
- Source
hasWebGL() → {boolean}
Check if this layer is using WebGL
- Source
- Type:
- boolean
updateWebGL()
Create WebGL texture if necessary and copy layer canvas to it
- Source