Rahul Gurung

Rahul Gurung

490 Articles Published

Articles by Rahul Gurung

Page 40 of 49

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

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 596 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. Syntax new fabric.Canvas(element: HTMLElement|String, { uniScaleKey: String }: Object) Parameters element − 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 ...

Read More

How to customize the viewport of the canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 2K+ Views

In this article, we are going to learn how to customize the viewport of the canvas using FabricJS. The viewport is the visible area of the canvas that users can see. We can customize the viewport using the viewportTransform property, which allows us to control transformations like scaling, translation, and skewing of the entire canvas view. What is viewportTransform? The viewportTransform property is a transformation matrix represented as an array of 6 values: [scaleX, skewY, skewX, scaleY, translateX, translateY]. This matrix transforms the entire canvas coordinate system, affecting how all objects are displayed. Syntax new ...

Read More

How to clone a canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 2K+ Views

In this article, we are going to learn how to clone a canvas using FabricJS. We can clone a canvas instance by using the clone() method. Usually, this is useful when we want to send our canvas instance remotely to somewhere else, it is usually a good idea to send the canvas instance clone in JSON form instead of sending the image of the canvas. clone() method helps us create a clone of any canvas instance along with its objects. Syntax clone(callback: Function, propertiesToInclude: Array) Parameters ...

Read More

How to set the vertical scale factor of Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 234 Views

In this tutorial, we are going to learn how to set the vertical scale factor of a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. Just as we can specify the position, colour, opacity and dimension of a rectangle object in the canvas, we can also set the vertical scale of a rectangle object. This can be done by using the scaleY property. ...

Read More

How to set the width of stroke of Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 530 Views

In this tutorial, we are going to learn how to set the width of stroke of a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. The strokeWidth property allows us to specify the width of a stroke for an object in pixels. Syntax new fabric.Rect({ strokeWidth: Number }); Parameters ...

Read More

How to disable the centered scaling of Text using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 475 Views

In this tutorial, we are going to learn how to disable the centered scaling of Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. When being scaled via controls, assigning a true value to the centeredScaling property, uses the center as the object's origin of transformation. Syntax new fabric.Text(text: String, ...

Read More

How to add curves to a Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we are going to learn how to add curves to a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. We can customize a rectangle object by specifying its position, colour, opacity and dimension. However, we can also use properties like rx and ry which allow us to assign the horizontal and vertical border radius of a Rectangle. Syntax new fabric.Rect({ rx : Number, ry: Number }: ...

Read More

How to get the object scale factor of Text using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 307 Views

In this tutorial, we are going to learn how to get the object scale factor of Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can also find the object scale factor by using the getObjectScaling method. Syntax getObjectScaling() This method returns an object containing the scaleX ...

Read More

How to add dashed stroke to a Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 847 Views

In this tutorial, we are going to learn how to add a dashed stroke to a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. The strokeDashArray property allows us to specify a dash pattern for the object's stroke. Syntax new fabric.Rect({ strokeDashArray: Array }) Parameters Options (optional) − This parameter is an Object which provides additional ...

Read More

How to get the opacity of Text object using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 266 Views

In this tutorial, we are going to learn how to get the opacity of Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can also find the opacity of an object by using the getObjectOpacity method. Syntax getObjectOpacity() Example 1 Using the getObjectOpacity method Let's ...

Read More
Showing 391–400 of 490 articles
« Prev 1 38 39 40 41 42 49 Next »
Advertisements