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
Javascript Articles
Page 56 of 534
Adding rotation animation to a Polygon object using FabricJS
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 add rotation animation, we can use the angle property in conjunction with animate method. Syntax animate(property: String | Object, value: Number | Object): fabric.Object | fabric.AnimationContext | Array. Parameters ...
Read MoreConverting a Polygon object into a data-like URL string using FabricJS
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 a data-like URL string we use the toDataURL method. This method converts an object into a data-like URL string that represents the visual appearance of the polygon as a base64-encoded image. Syntax toDataURL(options: Object): ...
Read MoreConverting a polygon object into an HTMLCanvasElement using FabricJS
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. Syntax toCanvasElement( options: Object ): HTMLCanvasElement ...
Read MoreFabric.js – How to draw a hexagonal grid (honey comb) with Polygon class
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 MoreFabricJS – Applying scale multiplier to a Polygon converted to a HTMLCanvasElement
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 multiplier property to set a multiplier to the ...
Read MoreExplain non-boolean value coercion to a boolean one in JavaScript?
We will learn non-boolean value coercion to a Boolean one in JavaScript. For beginners, coercion word is new in JavaScript. So, let's clarify what coercion is. Coercion is converting the variable of one data type to another data type. As we all know, JavaScript is not a type-strict language. So, we don't need to define the types of the variable. Sometimes, JavaScript automatically coerces the variables and gives unpredictable results in the output. There are two types of coercion in JavaScript. One is implicit coercion, and another is explicit coercion. We will learn both coercion one by one ...
Read MoreExplain Passport in Node.js?
Passport is a popular Node.js authentication middleware that provides flexible authentication strategies. It handles user authentication, password encryption, and session management with minimal code complexity. Passport offers over 500 authentication strategies including local authentication, OAuth (Google, Facebook), JWT tokens, and more. It integrates seamlessly with Express.js and popular databases like MongoDB. Key Features Authentication Strategies: Passport supports multiple authentication methods through strategy plugins. The most common is passport-local for username/password authentication. Password Security: Automatically handles password hashing and verification using secure algorithms, protecting user credentials from being stored in plain text. Session Management: Maintains user ...
Read MoreExplain Popup Message using Event?
We can show popup messages to app users using JavaScript popup boxes. There are three different types of popup boxes available in JavaScript that trigger through events like button clicks. The three types of popup boxes are: Alert box - Shows a simple message Confirm box - Asks for user confirmation Prompt box - Collects user input Let's explore each popup type with event-driven examples. Alert Box The alert box displays a simple message to users. It's commonly used for notifications like "Login successful" ...
Read MoreExplain Promise.any() with async-await in JavaScript?
We will learn about the Promise.any() method in JavaScript and how to use it with async/await. In JavaScript, promises handle asynchronous operations, making applications faster by allowing code execution without waiting for slow operations to complete. What is Promise.any()? The Promise.any() method returns the first successfully resolved promise from an array of promises. It ignores rejected promises and only fails if all promises are rejected (throwing an AggregateError). Syntax Promise.any(iterable) .then(value => { // Handle first resolved value }) .catch(error => { ...
Read MoreExplain Promise.race() with async-await in JavaScript?
Promise.race() executes multiple promises concurrently and returns the result of whichever promise settles first, whether resolved or rejected. Unlike Promise.all(), it doesn't wait for all promises to complete. Syntax Promise.race(iterable) .then(result => { // Handle first settled promise }) .catch(error => { // Handle if first promise rejected }); // With async/await async function example() { try { const result = await Promise.race([promise1, promise2, promise3]); // Use result from first ...
Read More