Found 6683 Articles for Javascript

How to set a custom key to enable/disable uniform scaling on a canvas in FabricJS?

Rahul Gurung
Updated on 20-May-2022 06:34:17

319 Views

In this article, we are going to learn how to set a custom key to enable/disable uniform scaling in FabricJS. In FabricJS, an object gets transformed proportionally when dragged from its corners. This is called uniform scaling. However, we can enable/disable this behavior by using the uniScaleKey.Syntaxnew fabric.Canvas(element: HTMLElement|String, { uniScaleKey: String }: Object)Parameterselement − This parameter is the element itself which can be derived using Document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using ... Read More

How to enable selection of object only when it is fully contained in a selection area in FabricJS?

Rahul Gurung
Updated on 20-May-2022 06:27:37

619 Views

In this article, we are going to learn how to enable the selection of an object only when it is fully contained in the selection area using FabricJS. We can use the selectionFullyContained property to achieve this.Syntaxnew fabric.Canvas(element: HTMLElement|String, { selectionFullyContained: Boolean }: Object)Parameterselement − This parameter is the element itself which can be derived using Document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter, properties such as color, cursor, border width, and ... Read More

How to add dashes to the border of a selection area on a canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 13:40:08

350 Views

In this article, we are going to learn how to add dashes to the border of a selection area on a canvas using FabricJS. We can achieve this by using the selectionDashArray property. It allows us to make the border of a selection area dashed.Syntaxnew fabric.Canvas(element: HTMLElement|String, { selectionDashArray: Array }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter ... Read More

How to enable centered scaling on a canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 13:37:12

763 Views

In this article, we are going to learn how to enable centered scaling on a canvas using FabricJS. In FabricJS, an object gets transformed proportionally when dragged from the corners. We can use the centeredScaling property to use the center as the origin of transformation.Syntaxnew fabric.Canvas(element: HTMLElement|String, { centeredScaling: Boolean }: Object)Parameterselement − This parameter is the element itself which can be derived using Document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter ... Read More

How to disable uniform scaling in canvas using FabricJS?

Rahul Gurung
Updated on 24-Mar-2022 11:18:32

692 Views

In this article, we are going to learn about how to disable uniform scaling in canvas using FabricJS. In FabricJS, an object gets transformed proportionally when dragged from the corners. However, we can disable this behavior by using the uniformScaling property.Syntaxnew fabric.Canvas(element: HTMLElement|String, { uniformScaling: Boolean }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter, properties such as color, ... Read More

How to resize an object non-uniformly via corner points using FabricJS?

Rahul Gurung
Updated on 19-May-2022 13:32:34

657 Views

In this article, we are going to learn how to resize an object non-uniformly via corner points using FabricJS. In FabricJS, an object gets transformed proportionally when dragged from the corners. However, we can control this behavior by pressing the uniScaleKey.Syntaxnew fabric.Canvas(element: HTMLElement|String, { uniScaleKey: String }: Object)Parameterselement − This parameter is the element itself which can be derived using Document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter, properties such as color, ... Read More

How to set the width of a selection area border on a canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 13:29:02

598 Views

In this article, we are going to learn how to set the width of a selection area border on a canvas using FabricJS. A selection area indicates the area selected using the mouse and all objects under that area will get selected. FabricJS allows us to adjust the width of the selection area border with the selectionLineWidth property.Syntaxnew fabric.Canvas(element: HTMLElement|String, { selectionLineWidth: Number }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter ... Read More

How to set the color of a selection area on a canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 13:24:55

646 Views

In this article, we are going to learn how to set the color of a selection area on a canvas using FabricJS. We can adjust the color using the selectionColor property.Syntaxnew fabric.Canvas(element: HTMLElement|String, { selectionColor: String }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. Using this parameter, properties such as color, cursor, border width and a lot of other properties can ... Read More

How to set the border color of a selection area on a canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 12:39:06

676 Views

In this article, we are going to learn how to set the border color of a selection area on a canvas using FabricJS. A selection indicates whether a group selection should be enabled or not. FabricJS allows us to adjust the border color accordingly with the selectionBorderColor property.Syntaxnew fabric.Canvas(element: HTMLElement|String, { selectionBorderColor: String }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be initialized on this element.options (optional) − This parameter is an Object which provides additional customizations to our canvas. ... Read More

How to disable the interactivity of canvas using FabricJS?

Rahul Gurung
Updated on 19-May-2022 12:34:36

1K+ Views

In this article, we are going to learn how to disable the interactivity of canvas in FabricJS. The interactive layer on top of each object is one of the unique features of FabricJS. As soon as we initialize a canvas, it's possible to select the objects, drag them around or manipulate a group selection. However, all this can be undone by assigning the interactive property to False.Syntaxnew fabric.Canvas(element: HTMLElement|String, { interactive : Boolean }: Object)Parameterselement − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas ... Read More

Advertisements