p5.js | rotate() function
The rotate() function in p5.js is used to rotate a shape or the object using p5.js to a specified axis over a specified angle.
Syntax:
rotate(angle, [axis])
Parameters: The function accepts single parameter as mentioned above and described below:
- angle: The angle of rotation which specified in radians or degrees.
- axis: the axis to rotate around
Below program illustrates the rotate() function in p5.js:
Example-1:
function setup() { // Create Canvas of given size createCanvas(380, 170); } function draw() { // Set the background color background(220); strokeWeight(12); //set strokeJoin function strokeJoin(ROUND); // rotation function rotate(PI / 10.0); line(20, 30, 200, 30); line(200, 30, 200, 100); line(200, 100, 20, 30); } |
chevron_right
filter_none
Output:

Example-2:
function setup() { // Create Canvas of given size createCanvas(380, 170); } function draw() { // Set the background color background(220); strokeWeight(12); // rotation function rotate(PI / 7.0); textSize(30); text("GeeksForGeeks", 50, 50); } |
chevron_right
filter_none
Output:

Reference: https://p5js.org/reference/#/p5/rotate
Recommended Posts:
- CSS | hue-rotate() Function
- CSS | rotate() Function
- PHP | ImagickDraw rotate() Function
- PHP | Ds\Sequence rotate() Function
- PHP | Ds\Deque rotate() Function
- PHP | Ds\Vector rotate() Function
- Node Jimp | rotate
- HTML canvas rotate() Method
- How to rotate an HTML div element 90 degrees using JavaScript ?
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- p5.js | int() function
- D3.js | d3.sum() function
- PHP | pow( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



