Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the background colour of text lines with IText using FabricJS?

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

In this tutorial, we are going to learn how to set the background colour of text lines of IText using FabricJS. The IText class was introduced in FabricJS version 1.4, extends fabric.Text and is used to create IText instances. An IText instance gives us the freedom to select, cut, paste or add new text without additional configurations. There are also various supported key combinations and mouse/touch combinations which make text interactive which are not provided in Text. Textbox, however, which is based on IText allows us to resize the text rectangle and wraps lines automatically. This is not true for ...

Read More

How to set the angle of an Image using FabricJS?

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

In this tutorial, we are going to learn how to set the angle of an Image 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 set the angle of an Image, we use the angle property. Syntax new fabric.Image( element: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String, { angle: Number }: Object, callback: function) Parameters ...

Read More

FabricJS – Capturing the Stream of a Polygon Converted to a HTMLCanvasElement?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 403 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. In order to convert a polygon object into HTMLCanvasElement we use the toCanvasElement method. It returns the DOM element of type HTMLCanvasElement, an interface which inherits its properties and methods from the HTMLElement interface. We use the captureStream method to capture stream of Polygon converted ...

Read More

How to call a function that returns another function in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 39K+ Views

In JavaScript, calling a function that returns another function involves understanding higher-order functions and closures. When a function returns another function, you can either store the returned function in a variable or call it immediately using double parentheses. Basic Syntax There are two main ways to call a function that returns another function: // Method 1: Store in variable then call let returnedFunction = outerFunction(); returnedFunction(); // Method 2: Call immediately outerFunction()(); Simple Example let outerFunction = function() { ...

Read More

Reading JavaScript variables using Selenium WebDriver.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 3K+ Views

We can read JavaScript variables with Selenium WebDriver using the executeScript method. This method allows Selenium to execute JavaScript commands directly in the browser and return their results. To work with JavaScript in Selenium, we need to import org.openqa.selenium.JavascriptExecutor. Syntax JavascriptExecutor j = (JavascriptExecutor) driver; String result = (String) j.executeScript("return document.title"); Reading Document Properties The most common use case is reading document properties like title, URL, or DOM elements. Let's obtain the browser title by reading the JavaScript variable document.title. Example Here's a complete example that reads the page title ...

Read More

How to transform two or more spaces in a string in only one space? JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 375 Views

In JavaScript, you can transform multiple consecutive spaces in a string into a single space using regular expressions with the replace() method. This is useful for cleaning up text input or formatting strings consistently. The Regular Expression Approach The most effective method uses the regular expression /\s{2, }/g where: \s matches any whitespace character (spaces, tabs, newlines) {2, } matches two or more consecutive occurrences g is the global flag to replace all instances Method 1: Using replace() with Regular Expression ...

Read More

Converting an unsigned 32 bit decimal to corresponding ipv4 address in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

Converting a 32-bit unsigned integer to an IPv4 address involves extracting the four bytes that represent each octet of the IP address. Each IPv4 address consists of four octets (0-255), which can be extracted using bitwise operations. Understanding the Problem Consider the IPv4 address: 128.32.10.1 When converted to binary, each octet becomes an 8-bit binary number: 10000000.00100000.00001010.00000001 Combining these four 8-bit segments creates a 32-bit binary number, which equals the decimal value: 2149583361 Our task is to reverse this process: convert the 32-bit unsigned integer back ...

Read More

Finding peak of a centrally peaked array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 446 Views

A centrally peaked array is an array that increases to a peak element and then decreases. It has the following properties: Array length must be at least 3 There exists an index i where 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i-1] < arr[i] (strictly increasing) arr[i] > arr[i+1] ...

Read More

FabricJS to setting the Background Colour on Selection of Circle

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

In this tutorial, we are going to learn how to set the background colour of selection of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we have to create an instance of fabric.Circle class and add it to the canvas. We can change an object's dimensions, rotate it or manipulate it when the circle is actively selected. We can change the background colour of selection of Circle by using the selectionBackgroundColor property. Syntax new fabric.Circle({ selectionBackgroundColor: String }: Object) ...

Read More

How to lock the vertical skewing of a Triangle using FabricJS?

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

In this tutorial, we are going to learn how to lock the vertical skewing of a Triangle using FabricJS. Just as we can specify the position, colour, opacity and dimension of a triangle object in the canvas, we can also specify whether we want to stop skewing an object vertically. This can be done by using the lockSkewingY property. Syntax new fabric.Triangle({ lockSkewingY : Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations ...

Read More
Showing 15291–15300 of 61,297 articles
Advertisements