Articles on Trending Technologies

Technical articles with clear explanations and examples

Finding the k-prime numbers with a specific distance in a range in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 500 Views

K-Prime Numbers A natural number is called k-prime if it has exactly k prime factors, counted with multiplicity. For example, 4 is a 2-prime number because 4 = 2 × 2, and both instances of 2 are counted separately. Similarly, 8 is a 3-prime number because 8 = 2 × 2 × 2, giving us three prime factors. Problem We need to write a JavaScript function that takes a number k, a distance, and a range. The function should return an array of pairs containing k-prime numbers within the range where the distance between them equals ...

Read More

How to set the angle of skew on the X-axis of a Circle using FabricJS?

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

In this tutorial, we are going to learn how to set the angle of skew on X-axis of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will create an instance of fabric.Circle class and add it to the canvas. Our circle object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on X-axis. We can do this by using the skewX property. Syntax new fabric.Circle({ skewX : Number }: Object) ...

Read More

How to lock the vertical scaling of Triangle using FabricJS?

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

In this tutorial, we are going to learn how to lock the vertical scaling 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 scaling an object vertically. This can be done by using the lockScalingY property. Syntax new fabric.Triangle({ lockScalingY : Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our triangle. Using this parameter, ...

Read More

How to set a multiplier to scale by in the URL string of IText object using FabricJS?

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

In this tutorial, we are going to learn about how to set a multiplier to scale by in the URL string of IText object 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 ...

Read More

How to set Image objects properties from options using FabricJS?

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

In this tutorial, we are going to learn how to set Image objects properties from options 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 Image objects properties from options, we use the setOptions method. Syntax setOptions(options: Object) Parameters options (optional) − This parameter is an Object which provides additional customizations to our object. Using this parameter ...

Read More

Sorting only a part of an array JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 935 Views

We are required to write a JavaScript function that takes in an array of strings as the first argument and two numbers as second and third argument respectively. The purpose of our function is to sort the array. But we have to sort only that part of the array that falls between the start and end indices specified by second and third argument. Keeping all the other elements unchanged. For example: const arr = ['z', 'b', 'a']; sortBetween(arr, 0, 1); This function should sort the elements at 0 and 1 index only. And the ...

Read More

Converting decimal to binary or hex based on a condition in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 259 Views

Problem We need to write a JavaScript function that takes in a number n and converts it based on a condition: If a number is even, convert it to binary. If a number is odd, convert it to hex. Solution We can use JavaScript's toString() method with different radix values to perform the conversion. For binary conversion, we use radix 2, and for hexadecimal conversion, we use radix 16. Example Here's the implementation: const num = 1457; const conditionalConvert = (num = 1) ...

Read More

Finding score of brackets in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 279 Views

We are required to write a JavaScript function that takes in a balanced square bracket string as an argument and computes its score based on specific rules. Scoring Rules The bracket scoring follows these rules: [] has score 1 AB has score A + B, where A and B are balanced bracket strings [A] has score 2 * A, where A is a balanced bracket string Example Input and Output For the input string '[][]': Input: '[][]' Output: 2 This works because [] scores 1, and [][] is two ...

Read More

How to set the angle of skew on the Y-axis of a Circle using FabricJS?

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

In this tutorial, we are going to learn how to set the angle of skew on Y-axis of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. Our circle object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on Y-axis. We can do this by using the skewY property. Syntax new ...

Read More

How to maintain stroke width of a Rectangle while scaling using FabricJS?

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

In this tutorial, we are going to learn how we can maintain the stroke width of Rectangle while scaling using FabricJS. By default, the stroke width increases or decreases with respect to the object's scale values. However, we can disable this behaviour by using the strokeUniform property. Syntax new fabric.Rect({ strokeUniform: Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides additional customizations to our rectangle. Using this parameter, properties such as colour, cursor, stroke width, and a lot of other properties can be changed related to the object ...

Read More
Showing 15281–15290 of 61,297 articles
Advertisements