Marcel
Marcel

Reputation: 438

How to remove white space around edges of object in Fabric.js

I am using Fabric.js and have a canvas where I can add shapes to. But when you resize the objects, there is a white space around the edges that keeps growing as you make the shape bigger. Because of this, you cant place the shape perfectly in the corners. I already tried setting the padding to 0, but this does nothing.

Does someone know how to remove these white spaces?

EDIT: it has something to do with the background, because if i set the background color of the object to the same color they go away. But if I do this the sizes are not accurate.

But I cant figure out how to remove the background

Here you can see the white space around the edges

Not in the corner pefectly

Upvotes: 0

Views: 778

Answers (1)

melchiar
melchiar

Reputation: 2862

By default, FabricJS objects have a transparent stroke of 1. You can set a strokeWidth of 0 on your objects to avoid this issue.

rect.set('strokeWidth', 0);

See http://fabricjs.com/fabric-gotchas

Upvotes: 2

Related Questions