The getSource() method is used to get the source of the specified color value.
Syntax:
getSource()
Parameters: This method does not accept any parameters.
Return Value: This method returns the source of the specified color value. The returned source value will be in an array representation.
Example 1:
HTML
| <!DOCTYPE html> <html>  <head>   <!-- Adding the FabricJS library -->  <scriptsrc=   </script> </head>  <body> <scripttype="text/javascript">   // Calling the getSource() function over  // the specified color values  console.log(new fabric.Color("hsl(0, 100%, 50%)").getSource());  console.log(new fabric.Color("hsla(10%, 100%, 50%, 0.2)").getSource()); </script>  </body>  </html> | 
Output:
[255,0,0,1] [0,0,0,1]
Example 2:
HTML
| <!DOCTYPE html> <html>  <head>   <!-- Adding the FabricJS library -->  <scriptsrc=   </script> </head>  <body> <scripttype="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)";  var D = "rgb(10, 40, 13)";  var E = "rgba(10, 40, 13, 0.9)";   // Calling the getSource() function over  // the above specified color values  console.log(new fabric.Color(A).getSource());  console.log(new fabric.Color(B).getSource());  console.log(new fabric.Color(C).getSource());  console.log(new fabric.Color(D).getSource());  console.log(new fabric.Color(E).getSource()); </script>  </body>  </html> | 
Output:
[0,0,0,1] [72,59,55,1] [46,24,20,0.6] [10,40,13,1] [10,40,13,0.9]

 
                                    







