Constructor
new module:OffscreenCanvas(widthopt, heightopt, optionsopt)
Off-screen canvas constructor
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | Number | <optional> | 1 | Width of the canvas |
height | Number | <optional> | 1 | Height of the canvas |
options | ContainerOptions | <optional> | Specific options |
Members
(static) defaultOptions :OffscreenCanvasOptions
- OffscreenCanvasOptions
center
Return this scene center point
ctx :CanvasRenderingContext2D
- CanvasRenderingContext2D
height
height
size
Return the whole scene size
width
width
Methods
(static) getDrawingContext(width, height) → {CanvasRenderingContext2D}
Build a canvas context and returns it
Name | Type | Default | Description |
---|---|---|---|
width | Number | 1 | Width of the canvas |
height | Number | 1 | Height of the canvas |
- Type:
- CanvasRenderingContext2D
clear() → {OffScreenCanvas}
Erase the canvas
Itself
- Type:
- OffScreenCanvas
getImageData(vectorDefinitionopt) → {ImageData}
Return the whole canvas as data
Name | Type | Attributes | Description |
---|---|---|---|
vectorDefinition | VectorDefinition | <optional> | Box of data to extract |
- Type:
- ImageData
getRandomPosition() → {Position}
Return a random position within the scene
- Type:
- Position
render() → {OffScreenCanvas}
Render a container and its children into the canvas
Itself
- Type:
- OffScreenCanvas
setImageData(imageData, positionDefinitionopt)
Put data into the canvas
Name | Type | Attributes | Description |
---|---|---|---|
imageData | ImageData | Data to add to the canvas | |
positionDefinition | PositionDefinition | <optional> | Position of the data |
setImageSmoothing(enable) → {OffScreenCanvas}
Change the behavior for upscaled images, smoothing is good for pictures but bad for pixel-art
Name | Type | Description |
---|---|---|
enable | Boolean | Should the smoothing be active or not |
Itself
- Type:
- OffScreenCanvas
toImage(vectorDefinitionopt, typeopt) → {HTMLImageElement}
Return an image composed of its content
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
vectorDefinition | VectorDefinition | <optional> | Box to restrict exported data | |
type | String | <optional> | "image/png" | Data format. Supported format depend on the browser implementation (png or jpeg are the only safe choices) |
- Type:
- HTMLImageElement
Type Definitions
OffscreenCanvasOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fill | String | | <optional> | null | Background color |
opacity | Number | <optional> | 1 | Global opacity |