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:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix |
(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. |
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 |
Returns:
Layer content
Type
Buffer
Type Definitions
JPEGOptions
Defines JPEG options
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
quality | float | <optional> | 0.75 | Specifying the quality (0 to 1) |
progressive | boolean | <optional> | false | Enables progressive encoding |
chromaSubsampling | boolean | <optional> | true | Enables 2x2 chroma subsampling |
PNGFilterType
Enum used in PNGOptions
Properties:
Name | Type | Description |
---|---|---|
NO | object | Filters are not applied |
ALL | object | All filters are applied |
NONE | object | The scanline is transmitted unmodified |
SUB | object | The Sub filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel |
UP | object | The 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 |
AVG | object | The Average filter uses the average of the two neighboring pixels (left and above) to predict the value of a pixel |
PAETH | object | The 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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compressionLevel | int | <optional> | 6 | ZLIB compression level (between 0 and 9) |
filters | Rendering.Layer.PNGFilterType|Array.<Rendering.Layer.PNGFilterType> | <optional> | ALL | Compression filter(s) |
palette | Uint8ClampedArray | <optional> | For creating indexed PNGs. The palette of colors. Entries should be in RGBA order. | |
backgroundIndex | int | <optional> | 0 | For creating indexed PNGs. The index of the background color. |
resolution | int | <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. |