Class: InkCanvas2D
Rendering.2D.InkCanvas2D
Creates ink canvas connected with html canvas.This layer is the target of screen rendering.Use createInstance method to construct instance of this class.Since:
- version 3.0
Extends
Methods
blend(source, options)
Draws the content of the 'source'. The 'source' must use a texture storage.
Parameters:
Name | Type | Description |
---|---|---|
source | Rendering.2D.OffscreenLayer2D | Layer to be drawn |
options | Rendering.BlendOptions | Blending configuration |
Overrides:
clear(rectopt, coloropt)
Clears layer area with a color
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect|Common.Color | <optional> | bounds | Area to clear |
color | Common.Color | <optional> | Color.TRANSPERENT |
Overrides:
createImageData(pixels, rect) → {ImageData}
Creates image data object
Parameters:
Name | Type | Description |
---|---|---|
pixels | Uint8ClampedArray | Image data pixel values |
rect | Common.Rect |
Overrides:
Returns:
Pixels image data
Type
ImageData
createLayer(widthopt, heightopt) → Rendering.2D.OffscreenLayer2D
Creates OffscreenLayer2D instance
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | int|Size | <optional> | drawing surface width | |
height | int | <optional> | drawing surface height |
Returns:
layer for offscreen rendering
Type
draw(stroke) → Common.Rect
Draws points with a brush over the layer
Parameters:
Name | Type | Description |
---|---|---|
stroke | Stroke | Stroke model instance |
Overrides:
Returns:
Affected area
Type
drawStroke(brush, path, color, matrixopt) → Common.Rect
Draws points with a brush over the layer
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
brush | Rendering.2D.Brush2D | Rendering brush | |
path | PathBuilding.InkPath2D | Contours list, where contour is points list | |
color | Common.Color | Stroke color | |
matrix | Common.Matrix | <optional> | Transforms drawing context |
Overrides:
Returns:
Affected area
Type
fill(shape, color) → Common.Rect
Fills shape with color
Parameters:
Name | Type | Description |
---|---|---|
shape | PathBuilding.PolygonArray|PathBuilding.Polygon|Polygon|Rect | Control points to work with it |
color | Common.Color | Fill color |
Overrides:
Returns:
Affected area
Type
(async, abstract) getExportCanvas()
Overrides:
getImageData(rectopt) → {ImageData}
Read pixels data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | Area to read |
Overrides:
Returns:
Pixels image data
Type
ImageData
putImageData(imageData, xopt, yopt)
Write pixels data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
imageData | ImageData | An ImageData object containing the array of pixel values | ||
x | int | <optional> | 0 | Horizontal position (x coordinate) at which to place the image data in the destination layer |
y | int | <optional> | 0 | Vertical position (y coordinate) at which to place the image data in the destination layer |
Overrides:
readPixels(rectopt) → {Uint8ClampedArray}
Read pixels data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | Area to read |
Overrides:
Returns:
Array of pixel values
Type
Uint8ClampedArray
resize(width, height)
Resize layer
Parameters:
Name | Type | Description |
---|---|---|
width | int | New width |
height | int | New height |
Overrides:
setTransform(matrix)
Configures ink transformation over underlying layer
Parameters:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix |
Overrides:
(async) toBlob(rectopt, mimeTypeopt, qualityopt) → {Blob}
Exports layer content. Compatible in web environment.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | Area to read |
mimeType | string | <optional> | image/png | Supported values are image/png, image/jpeg and image/webp. |
quality | float | <optional> | 0.92 | A Number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp.If this argument is anything else, the default values 0.92 and 0.80 are used for image/jpeg and image/webp respectively. |
Overrides:
Returns:
Layer content
Type
Blob
(async) toBuffer(rectopt, mimeTypeopt, options) → {Buffer}
Exports layer content. Compatible in nodejs environment.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | Area to read |
mimeType | string | <optional> | image/png | Supported values are image/png and image/jpeg. |
options | Rendering.Layer.PNGOptions|Rendering.Layer.JPEGOptions |
Overrides:
Returns:
Layer content
Type
Buffer
writePixels(data, rectopt)
Write pixels data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data | Uint8ClampedArray|Uint8Array | Array of pixel values | ||
rect | Common.Rect | <optional> | bounds | Area to write |
Overrides:
(static) createInstance(canvas, widthopt, heightopt, contextAttributesopt) → Rendering.2D.InkCanvas2D
Creates ink canvas connected with html canvas.This layer is the target of screen rendering.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
canvas | HTMLCanvasElement | DOM element related with ink canvas in web environment or CanvasRenderingContext2D provider | ||
width | int | <optional> | 300 | Initial width |
height | int | <optional> | 150 | Initial height |
contextAttributes | Rendering.2D.ContextAttributes2D | <optional> | 2D context configuration |
Returns:
WILL canvas
Type