Class Resize

Resize image filter class

Example

const filter = new Resize();
object.filters.push(filter);
object.applyFilters(canvas.renderAll.bind(canvas));

Hierarchy

Constructors

Properties

fragmentSourceTOP: string
lanczosLobes: number

LanczosLobes parameter for lanczos filter, valid for resizeType lanczos

Param

Default


mainParameter?: keyof Resize

Name of the parameter that can be changed in the filter. Some filters have more than one parameter and there is no mainParameter

resizeType: TResizeType

Resize type for webgl resizeType is just lanczos, for canvas2d can be: bilinear, hermite, sliceHack, lanczos.

Default


scaleX: number

Scale factor for resizing, x axis

Param

Default


scaleY: number

Scale factor for resizing, y axis

Param

Default


vertexSource: string = vertexSource

Array of attributes to send with buffers. do not modify

defaults: Partial<TClassProperties<Resize>> = resizeDefaultValues
type: string = 'Resize'

The class type. Used to identify which class this is. This is used for serialization purposes and internally it can be used to identify classes. As a developer you could use instance of Class but to avoid importing all the code and blocking tree shaking we try to avoid doing that.

Accessors

Methods

  • bilinearFiltering

    Parameters

    • this: ResizeDuring2DResize
    • options: T2DPipelineState
    • oW: number

      Original Width

    • oH: number

      Original Height

    • dW: number

      Destination Width

    • dH: number

      Destination Height

    Returns ImageData

  • Generate vertex and shader sources from the necessary steps numbers

    Parameters

    • filterWindow: number

    Returns string

  • Returns a string that represent the current selected shader code for the filter. Used to force recompilation when parameters change or to retrieve the shader from cache

    Parameters

    • this: ResizeDuringWEBGLResize

    Returns string

  • Returns undefined | string | number | ((gl, program) => TWebGLAttributeLocationMap) | ((options) => TWebGLProgramCacheItem) | (() => {
        lanczosLobes: number;
        resizeType: TResizeType;
        scaleX: number;
        scaleY: number;
        type: string;
    }) | (() => {
        type: string;
    }) | ((gl, program) => {
        uDelta: null | WebGLUniformLocation;
        uTaps: null | WebGLUniformLocation;
    }) | ((this, gl, uniformLocations) => void) | ((this) => number) | ((this) => string) | ((this) => string) | ((this) => any[]) | ((filterWindow) => string) | ((this, options) => void) | ((options) => void) | (() => boolean) | ((lobes) => ((x) => number)) | ((this, options) => void) | ((options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((gl, fragmentSource?, vertexSource?) => {
        attributeLocations: TWebGLAttributeLocationMap;
        program: WebGLProgram;
        uniformLocations: TWebGLUniformLocationMap;
    }) | ((gl, attributeLocations, aPositionData) => void) | ((options) => void) | ((options) => void) | ((options) => void) | ((gl, texture, textureUnit) => void) | ((gl, textureUnit) => void) | (() => undefined | string | number | ((gl, program) => TWebGLAttributeLocationMap) | ((options) => TWebGLProgramCacheItem) | (() => {
        lanczosLobes: number;
        resizeType: TResizeType;
        scaleX: number;
        scaleY: number;
        type: string;
    }) | (() => {
        type: string;
    }) | ((gl, program) => {
        uDelta: null | WebGLUniformLocation;
        uTaps: null | WebGLUniformLocation;
    }) | ((this, gl, uniformLocations) => void) | ((this) => number) | ((this) => string) | ((this) => string) | ((this) => any[]) | ((filterWindow) => string) | ((this, options) => void) | ((options) => void) | (() => boolean) | ((lobes) => ((x) => number)) | ((this, options) => void) | ((options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((this, options, oW, oH, dW, dH) => ImageData) | ((gl, fragmentSource?, vertexSource?) => {
        attributeLocations: TWebGLAttributeLocationMap;
        program: WebGLProgram;
        uniformLocations: TWebGLUniformLocationMap;
    }) | ((gl, attributeLocations, aPositionData) => void) | ((options) => void) | ((options) => void) | ((options) => void) | ((gl, texture, textureUnit) => void) | ((gl, textureUnit) => void) | (() => string | number | ((gl: WebGLRenderingContext, program: WebGLProgram) => TWebGLAttributeLocationMap) | ... 29 more ... | undefined) | ((value) => void) | ((options) => void)) | ((value) => void) | ((options) => void)

  • Return WebGL uniform locations for this filter's shader.

    Parameters

    • gl: WebGLRenderingContext

      The GL canvas context used to compile this filter's shader.

    • program: WebGLProgram

      This filter's compiled shader program.

    Returns {
        uDelta: null | WebGLUniformLocation;
        uTaps: null | WebGLUniformLocation;
    }

    • uDelta: null | WebGLUniformLocation
    • uTaps: null | WebGLUniformLocation
  • hermiteFastResize

    Parameters

    • this: ResizeDuring2DResize
    • options: T2DPipelineState
    • oW: number

      Original Width

    • oH: number

      Original Height

    • dW: number

      Destination Width

    • dH: number

      Destination Height

    Returns ImageData

  • Generic isNeutral implementation for one parameter based filters. Used only in image applyFilters to discard filters that will not have an effect on the image Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )

    Returns boolean

  • Parameters

    • lobes: number

    Returns ((x) => number)

      • (x): number
      • Parameters

        • x: number

        Returns number

  • Filter lanczosResize

    Parameters

    • this: ResizeDuring2DResize
    • options: T2DPipelineState
    • oW: number

      Original Width

    • oH: number

      Original Height

    • dW: number

      Destination Width

    • dH: number

      Destination Height

    Returns ImageData

  • Send attribute data from this filter to its shader program on the GPU.

    Parameters

    • gl: WebGLRenderingContext

      The canvas context used to compile the shader program.

    • attributeLocations: Record<string, number>

      A map of shader attribute names to their locations.

    • aPositionData: Float32Array

    Returns void

  • Send data from this filter to its shader program's uniforms.

    Parameters

    • this: ResizeDuringWEBGLResize
    • gl: WebGLRenderingContext

      The GL canvas context used to compile this filter's shader.

    • uniformLocations: TWebGLUniformLocationMap

      A map of string uniform names to WebGLUniformLocation objects

    Returns void

  • Filter sliceByTwo

    Parameters

    • options: T2DPipelineState
    • oW: number

      Original Width

    • oH: number

      Original Height

    • dW: number

      Destination Width

    • dH: number

      Destination Height

    Returns ImageData

  • Returns object representation of an instance

    Returns {
        lanczosLobes: number;
        resizeType: TResizeType;
        scaleX: number;
        scaleY: number;
        type: string;
    }

    Object representation of an instance

    • lanczosLobes: number
    • resizeType: TResizeType
    • scaleX: number
    • scaleY: number
    • type: string

Generated using TypeDoc