Multiple clipping areas on Fabric.js canvas

This can be accomplished with Fabric using the clipTo property, but you have to ‘reverse’ the transformations (scale and rotation), in the clipTo function. When you use the clipTo property in Fabric, the scaling and rotation are applied after the clipping, which means that the clipping is scaled and rotated with the image. You have … Read more

Download Canvas as PNG in fabric.js giving network Error

The problem you are facing is not directly related to fabricjs, (nor canvas and not even javascript btw), but comes from limitations some browsers (including Chrome) does have on the maximum length for the src attribute of an Anchor Element (<a>) with the donwload attribute. When this limit is reached, then the only thing you’ve … Read more

Fabric.js – how to save canvas on server with custom attributes

Good question. If you’re adding custom properties to objects, those objects are likely “special” in some way. It seems like subclassing them would be a reasonable solution. For example, here’s how we would subclass a fabric.Image into a named image. Those image objects could then have names like “Gandalf” or “Samwise”. fabric.NamedImage = fabric.util.createClass(fabric.Image, { … Read more