Rahul Gurung

Rahul Gurung

490 Articles Published

Articles by Rahul Gurung

Page 41 of 49

How to add shadow to a Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to add a shadow 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. Our rectangle object can be customized in various ways like changing its dimensions, adding a background color, or even adding a shadow to it. We can add a shadow to the rectangle by using the shadow property. Syntax new fabric.Rect({ shadow: fabric.Shadow }) Parameters ...

Read More

How to get the scaled height of Text using FabricJS?

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

In this tutorial, we are going to learn how to get the scaled height 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's scaled height by using the getScaledHeight method. Syntax getScaledHeight() Example 1: Using the getScaledHeight method Let's see ...

Read More

How to add stroke to a Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to add 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. Our rectangle object can be customized in various ways like changing its dimensions, adding a background colour or by changing the colour of the line drawn around the object. We can do this by using the stroke property. Syntax new fabric.Rect({ stroke : String }: Object) ...

Read More

How to get the scaled width of Text using FabricJS

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

In this tutorial, we are going to learn how to get the scaled width 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's scaled width by using the getScaledWidth method. Syntax getScaledWidth() Example 1: Using the getScaledWidth Method Let's see ...

Read More

How to create a canvas with Rectangle using FabricJS?

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

In this tutorial, we are going to learn how to create a canvas with a Rectangle object 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. Syntax new fabric.Rect({ width: Number, height: Number }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our rectangle. Using this parameter, properties such as colour, ...

Read More

How to get the style of current selection in Text using FabricJS?

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

In this tutorial, we are going to learn how to get the style of current selection 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 style of current selection by using the getSelectionStyles method. Syntax getSelectionStyles(startIndexopt, endIndexopt, completeopt) Parameters ...

Read More

How to create a Rectangle with background colour using FabricJS?

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

In this tutorial, we are going to create a Rectangle with background colour 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 backgroundColor property allows us to assign a colour to our object's background. It is the colour of the container where the rectangle lives and is rectangular in shape for the rectangle. Syntax new fabric.Rect({ backgroundColor: String }: Object) Parameters ...

Read More

How to include Text object's default values in its serialization using FabricJS?

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

In this tutorial, we are going to learn how to include Text object's default values in its serialization 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 we can also add additional functionalities. Serialization is used in order to export canvas contents. In order to achieve this we use toObject() and toJSON() methods. The includeDefaultValues property allows us to include or omit the object's default values when being serialized. Syntax new fabric.Text(text: String, { includeDefaultValues: ...

Read More

How to create a Rectangle with border colour using FabricJS?

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

In this tutorial, we are going to create a Rectangle with border colour 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. Since FabricJS is extremely flexible, we are allowed to customize our rectangle object in any way we like. One of the properties that FabricJS provides is borderColor which allows us to manipulate the colour of the border when our object is active. Syntax new fabric.Rect({ borderColor: String }: Object) ...

Read More

How to make controlling corners of Text transparent using FabricJS?

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

In this tutorial, we are going to learn how to make the controlling corners of Text transparent 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. The transparentCorners property allows us to make the controlling corners of Text object transparent. Syntax new fabric.Text(text: String, { transparentCorners: Boolean }: Object) ...

Read More
Showing 401–410 of 490 articles
« Prev 1 39 40 41 42 43 49 Next »
Advertisements