Fabric.js: setShadow is not a function on Rect object

Created on 9 Apr 2020  路  2Comments  路  Source: fabricjs/fabric.js

Hi all,

Just filing a report here. I'm not able to add a shadow using the .setShadow object method. Any ideas whats going on? My app is pretty complex and all the other methods work fine. It's just this.

Version

4.0.0-beta.8

Information about environment

Which browsers?

Firefox 74.0 (64-bit)

Steps to reproduce

 // Create the new templateRect
    var templateRect = new fabric.Rect({
      originX: "left",
      originY: "top",
      left: originX,
      top: originY,
      width: templateWidth,
      height: templateHeight,
      fill: "#fff" /* use transparent for no fill */,
      //   strokeDashArray: [10, 10],
      stroke: "black",
      selectable: false,
      strokeWidth: 1,
    });
    templateRect.setShadow({
      color: "red",
      blur: 10,
      offsetX: 20,
      offsetY: 20,
    });
    // Add the templateRect to the canvas
    canvas.add(templateRect);
    canvas.renderAll();

Expected Behavior

Add a shadow to a Rect

Actual Behavior

TypeError: templateRect.setShadow is not a function

Most helpful comment

The setShadow() method was removed as of v4.0.0-beta.7 (see below). Use rect.set('shadow', new fabric.Shadow(options)) instead.

https://github.com/fabricjs/fabric.js/releases/tag/v4.0.0-beta.7

All 2 comments

The setShadow() method was removed as of v4.0.0-beta.7 (see below). Use rect.set('shadow', new fabric.Shadow(options)) instead.

https://github.com/fabricjs/fabric.js/releases/tag/v4.0.0-beta.7

Thank you man!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bevacqua picture bevacqua  路  4Comments

amancqlsys picture amancqlsys  路  5Comments

guettli picture guettli  路  4Comments

vleandersson picture vleandersson  路  4Comments

lyzs90 picture lyzs90  路  3Comments