The degreesToRadians() method is used to transform the value of the specified degree to its corresponding radians value.
Syntax:
degreesToRadians( degrees )
Parameters: This method accepts a parameter as mentioned above and described below:
- degrees: This parameter holds the specified degree values.
Return Value: This method returns the converted radian values.
Example 1:
HTML
<!DOCTYPE html> < html > Â
< head > Â Â Â Â <!-- Adding the FabricJS library --> Â Â Â Â < script src = Â Â Â Â </ script > </ head > Â
< body > Â Â Â Â < script type = "text/javascript" > Â
        // Calling degreesToRadians() function over         // some specified degree values         console.log(fabric.util.degreesToRadians(30));         console.log(fabric.util.degreesToRadians(45));         console.log(fabric.util.degreesToRadians(90));     </ script > </ body > Â
</ html > |
Output:
0.5235987755982988 0.7853981633974483 1.5707963267948966
Example 2:
HTML
<!DOCTYPE html> < html > Â
< head > Â Â Â Â <!-- Adding the FabricJS library --> Â Â Â Â < script src = Â Â Â Â </ script > </ head > Â
< body > Â Â Â Â < script type = "text/javascript" > Â
        // Specifying some degree values         var a = 0;         var b = 10; Â
        // Calling degreesToRadians() function over         // above specified degree value         console.log(fabric.util.degreesToRadians(a));         console.log(fabric.util.degreesToRadians(b));     </ script > </ body > Â
</ html > |
Output:
0 0.17453292519943295