Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptFabric.js toHsla() Method

Fabric.js toHsla() Method

The toHsla() method is used to convert any type of the specified color representation to it’s HSLA (hue, saturation, lightness, and alpha) representation.

Syntax:

toHsla()

Parameters: This method does not accept any parameter.

Return Value: This method returns color representation in HSLA format.

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Calling the toHsla() function over 
 // the specified color values
 console.log(new fabric.Color("rgb(10, 120, 150)").toHsla());
 console.log(new fabric.Color("rgba(100, 20, 255, 0.3)").toHsla());
</script>
  
</body>
  
</html>


Output:

hsla(193,88%,31%,1)
hsla(260,100%,54%,0.3)

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 = "rgb(0, 12, 50)";
 var B = "rgba(10, 13, 250, 0.1)";
 var C = "hex(ffffff)";
  
 // Calling the toHsla() function over 
 // the above specified color values
 console.log(new fabric.Color(A).toHsla());
 console.log(new fabric.Color(B).toHsla());
 console.log(new fabric.Color(C).toHsla());
</script>
  
</body>
  
</html>


Output:

hsla(226,100%,10%,1)
hsla(239,96%,51%,0.1)
hsla(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