Constructor
#
new module:OffscreenCanvas(widthopt, heightopt, optionsopt)
Off-screen canvas constructor
Parameters:
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
#
center
Return this scene center point
#
ctx :CanvasRenderingContext2D
#
height
#
height
#
size
Return the whole scene size
#
width
#
width
Methods
#
(static) getDrawingContext(width, height) → {CanvasRenderingContext2D}
Build a canvas context and returns it
Parameters:
Name |
Type |
Default |
Description |
width |
Number
|
1
|
Width of the canvas |
height |
Number
|
1
|
Height of the canvas |
Returns:
-
Type
-
CanvasRenderingContext2D
#
clear() → {OffScreenCanvas}
Returns:
-
Type
-
OffScreenCanvas
#
getImageData(vectorDefinitionopt) → {ImageData}
Return the whole canvas as data
Parameters:
Name |
Type |
Attributes |
Description |
vectorDefinition |
VectorDefinition
|
<optional>
|
Box of data to extract |
#
getRandomPosition() → {Position}
Return a random position within the scene
#
render() → {OffScreenCanvas}
Render a container and its children into the canvas
Returns:
-
Type
-
OffScreenCanvas
#
setImageData(imageData, positionDefinitionopt)
Parameters:
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
Parameters:
Name |
Type |
Description |
enable |
Boolean
|
Should the smoothing be active or not |
Returns:
-
Type
-
OffScreenCanvas
#
toImage(vectorDefinitionopt, typeopt) → {HTMLImageElement}
Return an image composed of its content
Parameters:
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) |
Returns:
-
Type
-
HTMLImageElement
Type Definitions
#
OffscreenCanvasOptions
Properties
Name |
Type |
Attributes |
Default |
Description |
fill |
String
|
Color
|
<optional>
|
null
|
Background color |
opacity |
Number
|
<optional>
|
1
|
Global opacity |