Tuesday, November 19, 2024
Google search engine
HomeLanguagesJavascriptFabric.js overlayWith() Method

Fabric.js overlayWith() Method

The overlayWith() method is used to overlay the given color with the color taken as it’s parameter.

Syntax:

overlayWith(otherColor)

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

  • otherColor: This parameter holds the specified color.

Return Value: This method returns the overlaid color.

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Calling the overlayWith() function over
 // the specified color values
 console.log(new fabric.Color("rgb(10, 40, 13)").overlayWith("rgb(10, 41, 13, 1)"));
</script>
  
</body>
  
</html>


Output:

{"_source":[10,41,13,1]}

Example 2:

HTML




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Initializing some color values in different color format
 var A = "hex(fff00f)";
 var B = "hsl(12%, 13%, 25%)";
 var C = "hsla(10%, 40%, 13%, 0.6)";
  
 // Calling the overlayWith() function over
 // the above specified color values
 console.log(new fabric.Color(A).overlayWith("rgb(10, 41, 13, 1)"));
 console.log(new fabric.Color(A).overlayWith("rgba(1, 4, 3, 0.2)"));
 console.log(new fabric.Color(A).overlayWith("hex(ffffff)"));
</script>
  
</body>
  
</html>


Output:

{"_source":[5,21,7,1]}
{"_source":[1,2,2,1]}
{"_source":[0,0,0,1]}

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments