Fabric.js fromHsla() Method
The fromHsla() method is used to return a new color object for the specified color in HSLA(hue saturation lightness and alpha) format.
Syntax:
fromHsla(color)
Parameters: This method accepts a parameter as mentioned above and described below:
- color: This parameter holds the specified string color value in HSLA format.
Return Value: This method returns a new color object in the format of “RGBA(Red-Green-Blue-Alpha)” for the specified color in HSLA format.
Example 1:
Javascript
<!DOCTYPE html>
<html>
<head>
<!-- Adding the FabricJS library -->
<script src=
</script>
</head>
<body>
<script type= "text/javascript" >
console.log(fabric.Color
.fromHsla( "hsla(0, 100%, 50%, 1.0)" ));
</script>
</body>
</html>
|
Output:
{"_source":[255,0,0,1]}
Example 2:
Javascript
<!DOCTYPE html>
<html>
<head>
<!-- Adding the FabricJS library -->
<script src=
</script>
</head>
<body>
<script type= "text/javascript" >
var Black = "hsla(0, 0% ,0%, 0.1)" ;
var Red = "hsla(0, 100%, 50%, 1.0)" ;
console.log(fabric.Color.fromHsla(Black));
console.log(fabric.Color.fromHsla(Red));
</script>
</body>
</html>
|
Output:
{"_source":[0,0,0,0.1]}
{"_source":[255,0,0,1]}
Last Updated :
03 Feb, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...