UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

81 lines 2.77 kB
import { BaseFilter } from './BaseFilter'; import type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs'; import { fragmentSource } from './shaders/convolute'; export type ConvoluteOwnProps = { opaque: boolean; matrix: number[]; }; export declare const convoluteDefaultValues: ConvoluteOwnProps; /** * Adapted from <a href="http://www.html5rocks.com/en/tutorials/canvas/imagefilters/">html5rocks article</a> * @example <caption>Sharpen filter</caption> * const filter = new Convolute({ * matrix: [ 0, -1, 0, * -1, 5, -1, * 0, -1, 0 ] * }); * object.filters.push(filter); * object.applyFilters(); * canvas.renderAll(); * @example <caption>Blur filter</caption> * const filter = new Convolute({ * matrix: [ 1/9, 1/9, 1/9, * 1/9, 1/9, 1/9, * 1/9, 1/9, 1/9 ] * }); * object.filters.push(filter); * object.applyFilters(); * canvas.renderAll(); * @example <caption>Emboss filter</caption> * const filter = new Convolute({ * matrix: [ 1, 1, 1, * 1, 0.7, -1, * -1, -1, -1 ] * }); * object.filters.push(filter); * object.applyFilters(); * canvas.renderAll(); * @example <caption>Emboss filter with opaqueness</caption> * const filter = new Convolute({ * opaque: true, * matrix: [ 1, 1, 1, * 1, 0.7, -1, * -1, -1, -1 ] * }); * object.filters.push(filter); * object.applyFilters(); * canvas.renderAll(); */ export declare class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> { opaque: ConvoluteOwnProps['opaque']; matrix: ConvoluteOwnProps['matrix']; static type: string; static defaults: ConvoluteOwnProps; static uniformLocations: string[]; getCacheKey(): keyof typeof fragmentSource; getFragmentSource(): string; /** * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image. * * @param {Object} options * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. */ applyTo2d(options: T2DPipelineState): void; /** * Send data from this filter to its shader program's uniforms. * * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects */ sendUniformData(gl: WebGLRenderingContext, uniformLocations: TWebGLUniformLocationMap): void; /** * Returns object representation of an instance * @return {Object} Object representation of an instance */ toObject(): { opaque: boolean; matrix: number[]; type: "Convolute"; }; } //# sourceMappingURL=Convolute.d.ts.map