Skip to main content

Class: OffscreenLayerGL

(abstract) Rendering.WebGL.OffscreenLayerGL(inkContext, options)

Storage for a bitmap data that can be manipulated or presented on the screen.It corresponds to a GL texture or a render buffer.It defines the ration between actual pixels and the abstract layer dimensions.Not constructable. InkCanvas creates such layers.

Constructor

(abstract) new OffscreenLayerGL(inkContext, options)

Parameters:
NameTypeDescription
inkContextRendering.InkContext
optionsRendering.WebGL.InkLayerOptions
Properties:
NameTypeDescription
canvasRendering.WebGL.InkCanvasGLInk canvas reference
boundsCommon.RectThe bounds of the layer. Equals to (0, 0, width, height).

Since:

  • version 1.3

Extends

Methods

blend(source, options)

Draws the content of the 'source'. The 'source' must use a texture storage.

Parameters:
NameTypeDescription
sourceRendering.WebGL.OffscreenLayerGLlayer to be drawn
optionsRendering.BlendOptionsblending configuration

clear(shapeopt, coloropt)

Clears layer area with a color

Parameters:
NameTypeAttributesDefaultDescription
shapeCommon.Rect|Polygon|PathBuilding.InkPath2D|Common.Color<optional>boundsArea to clear
colorCommon.Color<optional>TRANSPERENT

createImageData(pixels, rect) → {ImageData}

Creates image data object

Parameters:
NameTypeDescription
pixelsUint8ClampedArrayImage data pixel values
rectCommon.Rect
Returns:

Pixels image data

Type

ImageData

delete()

Release allocated WebGL resources

Overrides:

draw(Stroke) → Common.Rect

Draws points with a brush over the layer

Parameters:
NameTypeDescription
StrokeStrokemodel instance
Returns:

Affected area

Type

Common.Rect

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

Draws points with a brush over the layer

Parameters:
NameTypeAttributesDescription
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
matrixCommon.Matrix<optional>Transforms drawing context
Returns:

affected area

Type

Common.Rect

fill(shape, antiAliasingopt) → Common.Rect

Fills shape with color

Parameters:
NameTypeAttributesDefaultDescription
shapePathBuilding.PolygonArray|PathBuilding.Polygon|Polygon|RectControl points to work with it
antiAliasingboolean<optional>trueis anti aliasing is enabled
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
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

(async) readPixels(rectopt, postDivideAlphaopt) → {Uint8ClampedArray}

Read pixels data (async with WebGL2)

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
Returns:

pixels

Type

Uint8ClampedArray

resize(width, height)

Resize layer

Parameters:
NameTypeDescription
widthint
heightint

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

Home