Class Filter

Constructors

Methods

Constructors

  • Creates a filter instance that lets apply various filters on every shape that extends the class.

    Basically every [[ShapeModel]] has exposed [[ShapeModel.addFilter]] and [[ShapeModel.removeFilter]] to work with filters

    Parameters

    • board: Board

      The [[Board]]

    Returns Filter

    Example

    Adds a blur filter to background image

    editor.board.background.image.addFilter({
    name: 'Blur',
    options: {
    blurRadius: 20
    }
    })

    Example

    Adds blur and contrast filters to background image

    editor.board.background.image.addFilter([
    {
    name: 'Blur',
    options: {
    blurRadius: 20
    }
    },
    {
    name: 'Contrast',
    options: {
    contrast: 30
    }
    }
    ])

    Example

    Adds a contrast filter to all selected shapes

    editor.selection.addFilter({
    name: 'Contrast',
    options: {
    contrast: 30
    }
    })

    Example

    Remove contrast filter of selected items

    editor.selection.removeFilter({ name: Contrast' })
    

    Example

    Remove multiple filters

    editor.selection.removeFilter([
    { name: Contrast' },
    { customFn: theFunction },
    { name: 'Contrast' }
    ])

    Example

    Adds a custom filter to background image

    editor.selection.addFilter({
    customFn: imageData => theCustomFunction(imageData),
    })

    Example

    Directly access to filters

    editor.filters.apply([editor.board.background.image], {
    name: 'Grayscale',
    })

Methods

  • Applies a filter to the given shapes

    Parameters

    • shapes: ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]

      List of the [[ShapeModel | Shapes]]

    • filters: Filters | Filters[]

      The list of given [[Filters | Filter]]

    Returns void

  • Remove filters of the given shapes

    Parameters

    Returns void