Wednesday, July 3, 2024
HomeLanguagesJavascriptFabric.js toRgba() Method

Fabric.js toRgba() Method

The toRgba() method is used to convert any type of the specified color representation to it’s RGBA (Red Green Blue and Alpha) representation.

Syntax:

toRgba()

Parameters: This method does not accept any parameter.

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

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
  <!-- Adding the FabricJS library -->
  <script src=
  </script>
</head>
  
<body>
<script type="text/javascript">
  
 // Calling the toRgba() function over 
 // the specified color values
 console.log(new fabric.Color("hsl(0, 100%, 50%)").toRgba());
 console.log(new fabric.Color("hsla(10, 40%, 53%, 0.6)").toRgba());
</script>
  
</body>
  
</html>


Output:

rgba(255,0,0,1)
rgba(183,103,87,0.6)

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%)";
  
 // Calling the toRgba() function over 
 // the above specified color values
 console.log(new fabric.Color(A).toRgba());
 console.log(new fabric.Color(B).toRgba());
</script>
  
</body>
  
</html>


Output:

rgba(0,0,0,1)
rgba(72,59,55,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!

Nango Kalahttps://www.kala.co.za
Experienced Support Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Microsoft Excel, Customer Service, Microsoft Word, Technical Support, and Microsoft Office. Strong information technology professional with a Microsoft Certificate Solutions Expert (Privet Cloud) focused in Information Technology from Broadband Collage Of Technology.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments