1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to apply Blur to fabric object

Discussão em 'Angular' iniciado por mdjpgarrett, Julho 11, 2025.

  1. mdjpgarrett

    mdjpgarrett Guest

    I'm adding fabric rect like this:

    import * as fabric from 'fabric';



    addBlurBox() {
    const rect = new fabric.Rect({
    left: 100,
    top: 100,
    width: 200,
    height: 150,
    fill: 'rgba(255, 255, 255, 0.2)',
    stroke: 'gray',
    strokeWidth: 1,
    selectable: true,
    hasControls: true,
    });

    this.canvas.add(rect);
    this.canvas.setActiveObject(rect);
    }


    It adds fine but then when I try to add Blur to it like so:

    addBlurBox() {
    const rect = new fabric.Rect({
    left: 100,
    top: 100,
    width: 200,
    height: 150,
    fill: 'rgba(255, 255, 255, 0.2)',
    stroke: 'gray',
    strokeWidth: 1,
    selectable: true,
    hasControls: true,
    });

    rect.filters?.push(new fabric.FabricImage.filters.Blur({ blur: 0.3 })); <-- ERROR HERE
    rect.applyFilters(); <-- ERROR HERE

    this.canvas.add(rect);
    this.canvas.setActiveObject(rect);
    }


    it throws an error for filters and applyFilters():


    Property 'filters' does not exist on type 'Ellipse<{ left: number; top: number; rx: number; ry: number; strokeWidth: number; selectable: true; hasControls: true; originX: "center"; originY: "center"; }, SerializedEllipseProps, ObjectEvents>'
    ​

    and for Blur:


    Property 'Blur' does not exist on type 'typeof FabricImage'
    ​

    Continue reading...

Compartilhe esta Página