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:
Name | Type | Description |
---|---|---|
inkContext | Rendering.InkContext | |
options | Rendering.WebGL.InkLayerOptions |
Properties:
Name | Type | Description |
---|---|---|
canvas | Rendering.WebGL.InkCanvasGL | Ink canvas reference |
bounds | Common.Rect | The 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:
Name | Type | Description |
---|---|---|
source | Rendering.WebGL.OffscreenLayerGL | layer to be drawn |
options | Rendering.BlendOptions | blending configuration |
clear(shapeopt, coloropt)
Clears layer area with a color
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shape | Common.Rect|Polygon|PathBuilding.InkPath2D|Common.Color | <optional> | bounds | Area to clear |
color | Common.Color | <optional> | TRANSPERENT |
createImageData(pixels, rect) → {ImageData}
Creates image data object
Parameters:
Name | Type | Description |
---|---|---|
pixels | Uint8ClampedArray | Image data pixel values |
rect | Common.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:
Name | Type | Description |
---|---|---|
Stroke | Stroke | model instance |
Returns:
Affected area
Type
drawStroke(brush, path, drawContext, matrixopt) → Common.Rect
Draws points with a brush over the layer
Parameters:
Name | Type | Attributes | 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 | |
matrix | Common.Matrix | <optional> | Transforms drawing context |
Returns:
affected area
Type
fill(shape, antiAliasingopt) → Common.Rect
Fills shape with color
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shape | PathBuilding.PolygonArray|PathBuilding.Polygon|Polygon|Rect | Control points to work with it | ||
antiAliasing | boolean | <optional> | true | is anti aliasing is enabled |
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 |
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 |
(async) readPixels(rectopt, postDivideAlphaopt) → {Uint8ClampedArray}
Read pixels data (async with WebGL2)
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 |
Returns:
pixels
Type
Uint8ClampedArray
resize(width, height)
Resize layer
Parameters:
Name | Type | Description |
---|---|---|
width | int | |
height | int |
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 |