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
Finding minimum flips in a binary string using JavaScript
A monotonically increasing binary string consists of some number of '0's (possibly zero) followed by some number of '1's (also possibly zero). Examples include "000", "111", "0011", or "01". Problem Statement Given a binary string, we need to find the minimum number of flips required to make it monotonically increasing. We can flip any '0' to '1' or any '1' to '0'. For example, with input "00110", we can flip the last '0' to '1' to get "00111", which requires only 1 flip. Approach Using Dynamic Programming We use memoization to track the minimum flips ...
Read MoreHow to create a canvas with a crosshair cursor using FabricJS?
In this article, we are going to create a canvas with a crosshair cursor using FabricJS. Crosshair is one of the native cursor styles available, which can be used in the FabricJS canvas too. FabricJS provides various types of cursors like default, all-scroll, crosshair, col-resize, row-resize, etc. which are reusing the native cursor under the hood. Each of these cursors look slightly different based on operating system. Syntax new fabric.Canvas(element: HTMLElement|String, { defaultCursor: String }: Object) Parameters element − This parameter is the ...
Read MoreHow to set the dash pattern of controlling corners of Ellipse using FabricJS?
In this tutorial, we are going to learn how we can implement the dash pattern of controlling corners of Ellipse using FabricJS. The controlling corners of an object allow us to scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific color to it, changing its size etc. We can also specify a dash pattern for the controlling corners by using the cornerDashArray property. Syntax new fabric.Ellipse({ cornerDashArray: Array }: Object) Parameters ...
Read MoreHow to create a Triangle with background colour using FabricJS?
In this tutorial, we are going to create a Triangle with background colour 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 backgroundColor property allows us to assign a colour to our object's background. It is the colour of the container where the Triangle lives and is rectangular in shape for the triangle. Syntax new fabric.Triangle({ backgroundColor: String }: Object) Parameters ...
Read MoreHow to set the angle of skew on the Y-axis of a Textbox using FabricJS?
In this tutorial, we are going to learn how to set the angle of skew on the y-axis of a Textbox using FabricJS. We can customize, stretch or move around the text written in a textbox. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. Our textbox object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on the y-axis. We can do this by using the skewY property. Syntax new fabric.Textbox(text: ...
Read MoreHow to change the font family of IText using FabricJS?
In this tutorial, we are going to learn about how to change the font family 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 automatically. This is not true for ...
Read MoreHow to convert JavaScript datetime to MySQL datetime?
Date time manipulation in JavaScript is important while dealing with databases. JavaScript Date and time are different from the MySQL date and time. JavaScript provides multiple ways to represent Date and time none of these formats are the same as MySQL's date and time format. In this article, we will discuss some approaches to converting JS date and time into MySQL date and time format. First of all, we will understand the difference between Javascript and MySQL date and time formats. Here is an example − Javascript − ISO 8601 Date Format: YYYY-MM-DDTHH:mm:ss.sssZ MySQL ...
Read MoreCheck if the elements of the array can be rearranged to form a sequence of numbers or not in JavaScript
We are required to write a JavaScript function that takes in an array of numbers and checks if the elements of the array can be rearranged to form a sequence of numbers or not. For example: If the array is − const arr = [3, 1, 4, 2, 5]; Then the output should be true because these numbers can be rearranged to form the consecutive sequence: 1, 2, 3, 4, 5. Approach To solve this problem, we need to: Sort the array in ascending order Check if each element is exactly ...
Read MoreFlatten array to 1 line in JavaScript
Suppose, we have a nested array of numbers like this − const arr = [ [ 0, 0, 0, -8.5, 28, 8.5 ], [ 1, 1, -3, 0, 3, 12 ], [ 2, 2, -0.5, 0, 0.5, 5.3 ] ]; We are required to write a JavaScript function that takes in one such nested array of numbers. The function should combine all the numbers in the nested array to form a single string. In the resulting string, the adjacent numbers should be separated by whitespaces and ...
Read MoreJavaScript - How to create nested unordered list based on nesting of array?
In this tutorial, we'll learn how to create nested unordered lists in HTML using JavaScript. We'll use recursion to traverse nested arrays and generate the corresponding HTML structure dynamically. Understanding the Problem We need to convert a nested array structure into an HTML unordered list where: String elements become list items Array elements become nested sublists The structure preserves the original nesting levels For example: Coffee ...
Read More