Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to set the padding of Image using FabricJS?
In this tutorial, we are going to learn how to set the padding of 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 padding of Image, we use the padding property. Syntax new fabric.Image( element: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String, { padding: Number }: Object, callback: function) Parameters ...
Read MoreHow to setup Video.js with JavaScript?
In this tutorial, we're going to learn how to set up Video.js using JavaScript. We'll also have a look at a few examples for better understanding. Video.js is a popular and easy-to-use modern web video player built on HTML5. It provides enhanced features and functionality for web video players, supporting various video formats including standard HTML5 formats and modern formats like YouTube, Vimeo, and Flash. It works seamlessly across all display sizes including desktops and mobile devices. Installing Video.js Video.js is officially available through CDN and npm (node package manager). Let's look at both installation methods. ...
Read MoreCounting prime numbers from 2 upto the number n JavaScript
We are required to write a JavaScript function that takes in a number, say n, as the first and the only argument. The function should then return the count of all the prime numbers from 2 up to the number n (exclusive). For example: For n = 10, the output should be: 4 (2, 3, 5, 7) For n = 1, the output should be: 0 Understanding Prime Numbers A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime ...
Read MoreCutting off number at each digit to construct an array in JavaScript
We need to write a JavaScript function that takes a number and returns an array of strings, where each string represents the number cut off at each digit position. Problem Given a number like 246, we want to create an array containing: First digit: "2" First two digits: "24" All digits: "246" Example Here's the implementation: const num = 246; const cutOffEach = (num = 1) => { const str = String(num); const res = []; let temp = ''; ...
Read MoreCorresponding shortest distance in string in JavaScript
We are required to write a JavaScript function that takes in a string of English lowercase alphabets, str, as the first argument and a single character, char, which exists in the string str, as the second argument. Our function should prepare and return an array which, for each character in string str, contains its distance from the nearest character in the string specified by char. Problem Example For example, if the input to the function is: const str = 'somestring'; const char = 's'; The expected output should be: const output ...
Read MoreHow to set the height of a Circle using FabricJS?
In this tutorial, we are going to learn how to set the height 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 manipulate a circle object by changing its position, opacity, stroke and also its dimension. FabricJS allows us to control an object's dimensions by using the width and height properties. Syntax new fabric.Circle({ height: Number }: Object) Parameters ...
Read MoreHow to make the controlling corners of a Triangle transparent using FabricJS?
In this tutorial, we are going to learn how to make the controlling corners of Triangle transparent using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a Triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. The transparentCorners property allows us to make the controlling corners of Triangle transparent. Syntax new fabric.Triangle( { transparentCorners: Boolean }: Object) Parameters Options (optional) − This parameter is an Object which provides ...
Read MoreHow to set the text alignment in IText using FabricJS?
In this tutorial, we are going to learn how to set the text alignment of text in 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 MoreFabricJS – How to change the format of the URL string of a Line object?
In this tutorial, we are going to learn about how to change the format of the URL string of Line object using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the x and y coordinates of the line and adding it to the canvas. In order to change the format of the URL string of Line object we use ...
Read MoreDetermining isomorphic strings JavaScript
Two strings are isomorphic if characters in one string can be mapped to characters in another string while preserving the structure. Each character must map to exactly one character, and no two characters can map to the same character. Understanding Isomorphic Strings For strings to be isomorphic: They must have the same length Characters at the same positions must follow a consistent mapping pattern The mapping must be bijective (one-to-one) Example const str1 = 'egg'; const str2 = 'add'; // Check if strings are isomorphic const isIsomorphic = (str1 = '', str2 ...
Read More