Open In App

Fabric.js Path dirty Property

Last Updated : 08 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to set the dirty of a Path using Fabric.js. The Path in Fabric.js is movable and can be stretched according to requirements. Further, the Path can be customized when it comes to initial stroke color, height, width, fill color, or stroke width.

Approach: To make it possible we are going to use a JavaScript library called Fabric.js. After importing the library, we will create a canvas block in the body tag that will contain the Path. After this, we will initialize instances of Canvas and Path provided by Fabric.js and set the dirty property of canvas Path using dirty property.

Syntax:

fabric.Path('path', {
   dirty: Boolean
});

Parameters: This function accepts a single parameter as mentioned above and described below:

  • dirty: It specifies the object cache will be rerendered next render call or not.

Below examples illustrate the use of Fabric.js Path dirty property in JavaScript:

Example:

HTML




<!DOCTYPE html> 
<html
  
  <head>
    <!-- FabricJS CDN -->
    <script src
    </script
  </head
  
  <body
    <div style="text-align: center;width: 400px;"
      <h1 style="color: green;"
        GeeksforGeeks 
      </h1>
      <b
        Fabric.js Path dirty Property 
      </b
    </div
  
    <div style="text-align: center;"
      <canvas id="canvas" width="400" height="200"
              style="border:1px solid green;"
      </canvas
    </div
  
    <script
      // Initiate a Canvas instance 
      var canvas = new fabric.Canvas("canvas"); 
  
      var geek = new fabric.Path('M 0 0 L 100 100 L 0 100 z', {
        fill: 'green',
        cornerStyle: 'circle',  
        dirty: false 
      });
  
      canvas.add(geek);
    </script
  </body
  
</html>


Output:



Similar Reads

Fabric.js | Rect dirty Property
In this article, when we set the dirty property to true then the object cache will be rerendered next render call to canvas rectangle using FabricJS. The canvas rectangle means rectangle is movable and can be stretched according to requirement. Further, the rectangle can be customized when it comes to initial stroke color, height, width, fill color
2 min read
Fabric.js Polygon dirty Property
In this article, when we set the dirty property to true then the object cache will be rerendered next render call to canvas Polygon using FabricJS. The canvas Polygon means Polygon is movable and can be stretched according to requirement. Further, the Polygon can be customized when it comes to initial stroke color, height, width, fill color, or str
2 min read
Fabric.js Polyline dirty Property
In this article, we are going to see how to use the dirty property of the canvas Polyline in Fabric.js. The Polyline in Fabric.js is movable and can be stretched according to requirement. Further, the Polyline can be customized when it comes to initial stroke color, height, width, fill color, or stroke width. When the dirty property is set to true,
2 min read
Fabric.js Group dirty Property
In this article, we are going to see how to set the dirty of a Group of the canvas using Fabric.js. The Group in Fabric.js is movable and can be stretched according to requirements. Further, the Group can be customized when it comes to initial stroke color, height, width, fill color, or stroke width. To make it possible we are going to use a JavaSc
2 min read
Fabric.js Image dirty Property
In this article, when we set the dirty property to true then the object cache will be rerendered next render call to canvas Image using FabricJS. The canvas Image means the Image is movable and can be stretched according to requirement. Further, the Image can be customized when it comes to initial stroke color, height, width, fill color, or stroke
2 min read
Fabric.js Text dirty Property
In this article, we are going to see how to change the dirty of the text canvas using Fabric.js. The canvas means the text written is movable, rotatable, resizable, and can be stretched. Further, the text itself cannot be edited like a textbox. To make it possible, we are going to use a JavaScript library called Fabric.js. After importing the libra
2 min read
Fabric.js ActiveSelection dirty Property
Fabric.js is a JavaScript library that is used to work with canvas. The canvas ActiveSelection is one of the class of Fabric.js that is used to create ActiveSelection instances. The canvas ActiveSelection means the ActiveSelection is movable and can be stretched according to requirement. In this article we will be using dirty property. Approach: Fi
2 min read
What's the difference between ng-pristine and ng-dirty in AngularJS ?
AngularJS supports client-side form validation. AngularJS keeps track of all the form and input fields and it also stores the information about whether anyone has touched or modified the field or not. The two different classes ng-dirty and ng-pristine that are used for form validation, are described below: ng-pristine: The ng-pristine class tells t
2 min read
Explain dirty checks in React.js
Dirty Checks in React generally refer to the changes and modifications in the DOM if a component state is modified or dirtied and needs re-rendering making the React DOM updates efficient. Prerequisites:React JS Virtual DOMReact JS Diffing AlgorithmReact JS ReconciliationReact uses virtual DOM to render the content. The DOM is an abstraction of a p
2 min read
Fabric.js Path borderDashArray Property
In this article, we are going to see how to set the borderDashArray of a Path using Fabric.js. The Path in Fabric.js is movable and can be stretched according to requirements. Further, the Path can be customized when it comes to initial stroke color, height, width, fill color, or stroke width. To make it possible we are going to use a JavaScript li
2 min read