Skip to main content

Class: Layer

(abstract) Rendering.Layer()

Generic layer definition

Constructor

(abstract) new Layer()

Methods

(async, abstract) getExportCanvas()

setTransform(matrix)

Configures ink transformation over underlying layer

Parameters:
NameTypeDescription
matrixCommon.Matrix

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

Layer content

Type

Buffer

Type Definitions

JPEGOptions

Defines JPEG options

Properties:
NameTypeAttributesDefaultDescription
qualityfloat<optional>0.75Specifying the quality (0 to 1)
progressiveboolean<optional>falseEnables progressive encoding
chromaSubsamplingboolean<optional>trueEnables 2x2 chroma subsampling

PNGFilterType

Enum used in PNGOptions

Properties:
NameTypeDescription
NOobjectFilters are not applied
ALLobjectAll filters are applied
NONEobjectThe scanline is transmitted unmodified
SUBobjectThe Sub filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel
UPobjectThe Up filter is just like the Sub filter except that the pixel immediately above the current pixel, rather than just to its left, is used as the predictor
AVGobjectThe Average filter uses the average of the two neighboring pixels (left and above) to predict the value of a pixel
PAETHobjectThe Paeth filter computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value

PNGOptions

Defines PNG options

Properties:
NameTypeAttributesDefaultDescription
compressionLevelint<optional>6ZLIB compression level (between 0 and 9)
filtersRendering.Layer.PNGFilterType|Array.<Rendering.Layer.PNGFilterType><optional>ALLCompression filter(s)
paletteUint8ClampedArray<optional>For creating indexed PNGs. The palette of colors. Entries should be in RGBA order.
backgroundIndexint<optional>0For creating indexed PNGs. The index of the background color.
resolutionint<optional>PPI.Note that the PNG format encodes the resolution in pixels per meter, so if you specify 96, the file will encode 3780 ppm (~96.01 ppi).The resolution is undefined by default to match common browser behavior.

Home