Skip to main content

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:
NameTypeDescription
sourceRendering.2D.OffscreenLayer2DLayer to be drawn
optionsRendering.BlendOptionsBlending configuration

Overrides:

clear(rectopt, coloropt)

Clears layer area with a color

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect|Common.Color<optional>boundsArea to clear
colorCommon.Color<optional>Color.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(widthopt, heightopt) → Rendering.2D.OffscreenLayer2D

Creates OffscreenLayer2D instance

Parameters:
NameTypeAttributesDefaultDescription
widthint|Size<optional>drawing surface width
heightint<optional>drawing surface height
Returns:

layer for offscreen rendering

Type

Rendering.2D.OffscreenLayer2D

draw(stroke) → Common.Rect

Draws points with a brush over the layer

Parameters:
NameTypeDescription
strokeStrokeStroke model instance

Overrides:

Returns:

Affected area

Type

Common.Rect

drawStroke(brush, path, color, matrixopt) → Common.Rect

Draws points with a brush over the layer

Parameters:
NameTypeAttributesDescription
brushRendering.2D.Brush2DRendering brush
pathPathBuilding.InkPath2DContours list, where contour is points list
colorCommon.ColorStroke color
matrixCommon.Matrix<optional>Transforms drawing context

Overrides:

Returns:

Affected area

Type

Common.Rect

fill(shape, color) → Common.Rect

Fills shape with color

Parameters:
NameTypeDescription
shapePathBuilding.PolygonArray|PathBuilding.Polygon|Polygon|RectControl points to work with it
colorCommon.ColorFill color

Overrides:

Returns:

Affected area

Type

Common.Rect

(async, abstract) getExportCanvas()

Overrides:

getImageData(rectopt) → {ImageData}

Read pixels data

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsArea to read

Overrides:

Returns:

Pixels image data

Type

ImageData

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) → {Uint8ClampedArray}

Read pixels data

Parameters:
NameTypeAttributesDefaultDescription
rectCommon.Rect<optional>boundsArea to read

Overrides:

Returns:

Array of pixel values

Type

Uint8ClampedArray

resize(width, height)

Resize layer

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(data, rectopt)

Write pixels data

Parameters:
NameTypeAttributesDefaultDescription
dataUint8ClampedArray|Uint8ArrayArray of pixel values
rectCommon.Rect<optional>boundsArea 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:
NameTypeAttributesDefaultDescription
canvasHTMLCanvasElementDOM element related with ink canvas in web environment or CanvasRenderingContext2D provider
widthint<optional>300Initial width
heightint<optional>150Initial height
contextAttributesRendering.2D.ContextAttributes2D<optional>2D context configuration
Returns:

WILL canvas

Type

Rendering.2D.InkCanvas2D

Home