Skip to main content

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:
NameTypeDescription
sourceRendering.WebGL.OffscreenLayerGLlayer to be drawn
optionsRendering.BlendOptionsblending configuration

Overrides:

clear(rectopt, coloropt)

Clears canvas backbuffer area with a color

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect|Common.Color<optional>boundsarea to clear
colorCommon.Color<optional>TRANSPERENT

Overrides:

createImageData(pixels, rect) → {ImageData}

Creates image data object

Parameters:
NameTypeDescription
pixelsUint8ClampedArrayImage data pixel values
rectCommon.Rect

Overrides:

Returns:

Pixels image data

Type

ImageData

createLayer(options) → Rendering.WebGL.OffscreenLayerGL

Creates OffscreenLayerGL instance

Parameters:
NameTypeDescription
optionsRendering.WebGL.InkLayerOptionsLayer 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:
NameTypeDescription
brushRendering.WebGL.BrushGL|Rendering.2D.Brush2DBrush instance determines how the stroke is going to be rendered
strokeStrokemodel instance

Overrides:

Returns:

affected area

Type

Common.Rect

drawStroke(brush, path, drawContext) → Common.Rect

Draws points with a brush over the canvas backbuffer

Parameters:
NameTypeDescription
brushRendering.WebGL.BrushGL|Rendering.2D.Brush2DBrush instance determines how the stroke is going to be rendered
pathPathBuilding.InterpolatedSplinespline to draw
drawContextRendering.WebGL.StrokeDrawContext|Common.ColorStrokeDrawContext instance (contains previous path point), applicable only when brush is BrushGL

Overrides:

Returns:

affected area

Type

Common.Rect

fill(path2D, antiAliasingopt) → Common.Rect

Fills path with color over the canvas backbuffer

Parameters:
NameTypeAttributesDefaultDescription
path2DPathBuilding.InkPath2D|PolygonControl points to work with it
antiAliasingboolean<optional>trueis anti aliasing is enabled

Overrides:

Returns:

affected area

Type

Common.Rect

(async, abstract) getExportCanvas()

Overrides:

(async) getImageData(rectopt, postDivideAlphaopt) → {ImageData}

Read pixels data

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsArea to read
postDivideAlphaboolean<optional>falseRecover 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:
NameTypeAttributesDefaultDescription
imageDataImageDataAn ImageData object containing the array of pixel values
xint<optional>0Horizontal position (x coordinate) at which to place the image data in the destination layer
yint<optional>0Vertical 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:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsarea to read
postDivideAlphaboolean<optional>falseresult 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:
NameTypeDescription
widthintnew width
heightintnew height

Overrides:

setTransform(matrix)

Configures ink transformation over underlying layer

Parameters:
NameTypeDescription
matrixCommon.Matrix

Overrides:

(async) toBlob(rectopt, mimeTypeopt, qualityopt) → {Blob}

Exports layer content. Compatible in web environment.

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsArea to read
mimeTypestring<optional>image/pngSupported values are image/png, image/jpeg and image/webp.
qualityfloat<optional>0.92A 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:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsArea to read
mimeTypestring<optional>image/pngSupported values are image/png and image/jpeg.
optionsRendering.Layer.PNGOptions|Rendering.Layer.JPEGOptions

Overrides:

Returns:

Layer content

Type

Buffer

writePixels(bytes, rectopt)

Write pixels data over canvas backbuffer

Parameters:
NameTypeAttributesDefaultDescription
bytesUint8Arraypixels data
rectCommon.Rect<optional>boundsarea 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:
NameTypeAttributesDefaultDescription
canvasHTMLCanvasElementDOM element related with ink canvas in web environment or WebGL provider
widthint<optional>300Initial width
heightint<optional>150Initial height
contextAttributesRendering.WebGL.WebGLContextAttributes<optional>WebGL context configuration
Returns:

WILL canvas

Type

Rendering.WebGL.InkCanvasGL

Home