Rahul Gurung

Rahul Gurung

490 Articles Published

Articles by Rahul Gurung

Page 47 of 49

Fabric.js – How to check if an Image object is fully contained within the area of another object?

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

In this tutorial, we are going to learn how to check if an Image object is fully contained within the area of another object using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to check if an Image object is fully contained within the area of another object, we use the isContainedWithinObject method. Syntax isContainedWithinObject(other: Object, absolute: Boolean, calculate: Boolean): Boolean Parameters other ...

Read More

How to add a clipping area on a Polygon using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. A clipping path restricts the area to which fill or stroke is applied in a Polygon object. Therefore, the parts of the polygon which lie outside the clipping path, will not be drawn. In order to add a clipping area we use the clipPath property. ...

Read More

FabricJS – How to create the instance of fabric.Image from its object representation?

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

In this tutorial, we are going to show how you can create the instance of fabric.Image from its object representation using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to create the instance of fabric.Image from its object representation, we use the fromObject method. Syntax fabric.Image.fromObject(object, callback) Parameters object − This parameter accepts ...

Read More

How to add the coordinates in a Polygon using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. We can add the coordinates in a polygon by using points property. Syntax new fabric.Polygon(points: Array, options: Object) Parameters points − This parameter accepts an Array which denotes the array of points that make up the polygon object. ...

Read More

How to add image smoothing for an Image using FabricJS?

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

In this tutorial, we are going to show how you can add image smoothing for an Image using FabricJS. Smoothing gives a smooth effect to the image. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to add image smoothing, we use the imageSmoothing property. Syntax new fabric.Image(element: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String, ...

Read More

How to create a canvas with Polygon using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Syntax new fabric.Polygon(points: Array, options: Object) Parameters points − This parameter accepts an Array which denotes the array of points that make up the polygon object. ...

Read More

How to center an Image object horizontally on current viewport of canvas using FabricJS?

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

In this tutorial, we are going to learn how to center an Image object horizontally on current viewport of canvas using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to center an Image object horizontally on current viewport of canvas, we use the viewportCenterH method. Syntax viewportCenterH(): fabric.Object Default appearance of the Image object Let's see a code example to see how our Image ...

Read More

How to create a Polygon with Polyline using FabricJS?

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

We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. Since Polygon extends fabric.Polyline, we can create a polygon instance by using polyline as well. Syntax new fabric.Polyline( points: Array, options: Object ) Parameters points − This parameter accepts an Array which denotes the array ...

Read More

How to add an object to a canvas using FabricJS?

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

In this article, we are going to learn how to add an object to the canvas by using the add method. After creating our canvas, we can populate it with various objects available in FabricJS like fabric.Circle, fabric.Ellipse or fabric.Line, etc. Syntax canvas.add(object: fabric.Object); Parameters object − This parameter is of type fabric.Object and holds the objects that we want to add to our canvas. Example 1: Creating Object Instance Inside canvas.add() Instead of creating the instance of an object first and then rendering it on the canvas by using ...

Read More

How to disable uniform scaling on a canvas using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 344 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. Syntax new fabric.Canvas(element: HTMLElement|String, { uniformScaling: Boolean }: 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 ...

Read More
Showing 461–470 of 490 articles
Advertisements