Found 6685 Articles for Javascript

FabricJS – Determining Whether fill or Stroke Should be Drawn First for a Polygon Object?

Rahul Gurung
Updated on 29-Dec-2022 18:32:40

133 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 determine whether fill or stroke should be drawn first, we use the paintFirst property. Syntax new fabric.Polygon( points: Array, { paintFirst: String }: Object ) Parameters points − This parameter accepts an Array which denotes the array of points that ... Read More

FabricJS – Check if the Cache is Dirty and Renderer is Required for a Polygon?

Rahul Gurung
Updated on 29-Dec-2022 18:33:13

258 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. We can check if the cache is dirty and the renderer is required by using the isCacheDirty method. This method checks whether the cache is dirty and thus lets FabricJS know that something in our canvas has changed which requires re-rendering. SyntaxisCacheDirty( skipCanvas: Boolean ) ... Read More

FabricJS – Check if a Polygon Object is Fully Contained within Another Object?

Rahul Gurung
Updated on 29-Dec-2022 18:33:56

399 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. We use the isContainedWithinObject to find whether a polygon object is fully contained within the area of another object. It can be used to test whether an object is fully contained within the area of another object. Syntax isContainedWithinObject(other: Object, absolute: Boolean, calculate: Boolean ... Read More

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

Rahul Gurung
Updated on 29-Dec-2022 18:34:29

232 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 to ... Read More

Explain JSON in AJAX?

Rushi Javiya
Updated on 29-Dec-2022 15:35:26

4K+ Views

JSON, or JavaScript Object Notation, is a simple format for exchanging data. It is a human−readable and machine−understandable format. It is based on a portion of Standard ECMA−262, Third Edition, December 1999's JavaScript Programming Language. Despite using conventions recognizable to programmers of the C family of languages (C, C++, Java, JavaScript, Perl, Python, and many others), JSON is a text format fully independent of the programming language. JSON is the best language for exchanging data due to its characteristics and simplicity. AJAX is a method of web development used to build interactive web applications. Web pages can request data from ... Read More

Explain RegExp in ES6?

Rushi Javiya
Updated on 29-Dec-2022 15:33:42

136 Views

The ES6 is the latest JavaScript version which was introduced in 2015. We will learn about all the features of RegExp means regular expression, which Es6 contains. What is the Regular Expression and Usage of it The regular expression is a string representing the particular search pattern containing the different characters, such as numeric, alphabetic, and special characters. Let’s understand the real−time usage of regular expression. We hope you all have filled out any form in the past and seen particular form field validation errors. For example, if you don’t enter the email with the ‘@’ character or enter a ... Read More

Explain Promise.allSettled() with async-await in JavaScript?

Rushi Javiya
Updated on 29-Dec-2022 15:24:03

6K+ Views

Promise.allSettled() is a method that takes an iterable of promises as an argument and returns a promise that is fulfilled when all of the promises in the iterable have been settled, meaning that they have either been fulfilled or rejected. When the returned promise is fulfilled, it is resolved with an array of objects containing information about the fulfilled or rejected promises. Each object has a status property, either fulfilled or rejected, and a value or reason property, respectively. For example, if you have an array of promises that represent network requests and want to know each request's status (whether ... Read More

Explain Promise.all with async-await in JavaScript?

Rushi Javiya
Updated on 29-Dec-2022 15:22:01

5K+ Views

Simple operations like adding two numbers or string manipulation codes execute sequentially in JavaScript and return the results instantly. But while coding for real−world applications, we frequently make time−taking calls to databases, APIs, and other applications. These longer calls don’t return the results instantly; they will rather return a promise. A promise is an object to represent the future results of an asynchronous operation. It is used to handle asynchronous processes' eventual success or failure. For instance, if you request some object from an API in JavaScript, you will be given a promise that the task will eventually be complete ... Read More

Explain Promise.race() with async-await in JavaScript?

Rushi Javiya
Updated on 29-Dec-2022 15:19:30

1K+ Views

We will learn about the Promise.race() method in this tutorial. As the name of the race() method suggests, promises passed as a parameter of the race() method do the race to execute. So, Whichever promise will be resolved first, will be executed only by the race() method, and other promises will never be executed. Promise.race() The Promise.race method in JavaScript allows you to wait for the first of a set of promises to be fulfilled or rejected, and to handle the result or error that occurs. It returns a promise that is fulfilled or rejected as soon as one of ... Read More

Explain Promise.any() with async-await in JavaScript?

Rushi Javiya
Updated on 29-Dec-2022 15:17:09

680 Views

We will learn about any() method of the promise in this tutorial. In JavaScript, we can use the promises to handle the asynchronous request. Writing the asynchronous code in our application to fetch the data makes it faster as it executes the other code without waiting for the data. Promise.any() Method As the name of any() method suggests, it will execute any promise fulfilled. So, whichever promise will resolve first, will be executed by the promise.any() method and others may or may not be executed. Also, all rejected promises were never executed by the promise.any() method. SyntaxUsers can follow the ... Read More

Advertisements