Class: InkCanvasGL
Rendering.WebGL.InkCanvasGL
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 1.0
See:
Extends
Methods
blend(source, options)
Draws the content of the 'source' over canvas backbuffer. The 'source' must use a texture storage.
Parameters:
Name | Type | Description |
---|---|---|
source | Rendering.WebGL.OffscreenLayerGL | layer to be drawn |
options | Rendering.BlendOptions | blending configuration |
Overrides:
clear(rectopt, coloropt)
Clears canvas backbuffer area with a color
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect|Common.Color | <optional> | bounds | area to clear |
color | Common.Color | <optional> | 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(options) → Rendering.WebGL.OffscreenLayerGL
Creates OffscreenLayerGL instance
Parameters:
Name | Type | Description |
---|---|---|
options | Rendering.WebGL.InkLayerOptions | Layer configuration |
Returns:
Layer for offscreen rendering
Type
Rendering.WebGL.OffscreenLayerGL
delete()
Release allocated WebGL resources
Overrides:
destroy()
Delete all underlying GL resources and destroy allocated GL context
draw(brush, stroke) → Common.Rect
Draws points with a brush over the canvas backbuffer
Parameters:
Name | Type | Description |
---|---|---|
brush | Rendering.WebGL.BrushGL|Rendering.2D.Brush2D | Brush instance determines how the stroke is going to be rendered |
stroke | Stroke | model instance |
Overrides:
Returns:
affected area
Type
drawStroke(brush, path, drawContext) → Common.Rect
Draws points with a brush over the canvas backbuffer
Parameters:
Name | Type | Description |
---|---|---|
brush | Rendering.WebGL.BrushGL|Rendering.2D.Brush2D | Brush instance determines how the stroke is going to be rendered |
path | PathBuilding.InterpolatedSpline | spline to draw |
drawContext | Rendering.WebGL.StrokeDrawContext|Common.Color | StrokeDrawContext instance (contains previous path point), applicable only when brush is BrushGL |
Overrides:
Returns:
affected area
Type
fill(path2D, antiAliasingopt) → Common.Rect
Fills path with color over the canvas backbuffer
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path2D | PathBuilding.InkPath2D|Polygon | Control points to work with it | ||
antiAliasing | boolean | <optional> | true | is anti aliasing is enabled |
Overrides:
Returns:
affected area
Type
(async, abstract) getExportCanvas()
Overrides:
(async) getImageData(rectopt, postDivideAlphaopt) → {ImageData}
Read pixels data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | Area to read |
postDivideAlpha | boolean | <optional> | false | Recover color from GL premultiplyed color transform, should be true when result targets 2D context |
Overrides:
Returns:
Pixels image data
Type
ImageData
isDeleted() → {boolean}
Overrides:
Returns:
Is underlying WebGL resources are deleted
Type
boolean
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, postDivideAlphaopt) → {Uint8Array}
Read pixels data from canvas backbuffer
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rect | Common.Rect | <optional> | bounds | area to read |
postDivideAlpha | boolean | <optional> | false | result pixels format uses premultiplyed alpha by default, when straight alpha pixels are needed pixels are processed |
Overrides:
Returns:
pixels
Type
Uint8Array
resize(width, height)
Resize canvas
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(bytes, rectopt)
Write pixels data over canvas backbuffer
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bytes | Uint8Array | pixels data | ||
rect | Common.Rect | <optional> | bounds | area to write |
Overrides:
(static) createInstance(canvas, widthopt, heightopt, contextAttributesopt) → Rendering.WebGL.InkCanvasGL
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 WebGL provider | ||
width | int | <optional> | 300 | Initial width |
height | int | <optional> | 150 | Initial height |
contextAttributes | Rendering.WebGL.WebGLContextAttributes | <optional> | WebGL context configuration |
Returns:
WILL canvas
Type