Melvin Kosisochukwu
Melvin Kosisochukwu

Reputation: 392

How can i manipulate all objects in fabricjs?

I am trying to set strokeWidth of all object in fabric js, but i cant find a way to manipulate all the objects on canvas, i tried creating a an array and pushing all items dropped on canvas to the array.

Upvotes: 0

Views: 279

Answers (1)

Oro
Oro

Reputation: 2596

I think you can use .getObjects() method of canvas. I made an example for you here https://codesandbox.io/s/mystifying-curran-bkwtk?file=/src/index.js

canvas.getObjects().forEach(obj => {
  obj.set({
    stroke: "brown",
    strokeWidth: 10
  });
});

Upvotes: 4

Related Questions