p5.Camera pan() Method
The pan() method of p5.Camera in p5.js is used to rotate the view, that is, pan the camera according to the given amount of rotation. The camera can be panned both to the left or right by rotating the camera anticlockwise or clockwise.
pan( angle )
Parameters: This method accepts a single parameter as mentioned above and described below:
- angle: It is a number that denotes the amount that the camera has to rotate. The units of rotation to be used can be specified using the angleMode() method. A value greater than 0 would rotate the camera counterclockwise, that is, pan the camera to the left. Similarly, for negative values, the camera would rotate in the clockwise direction.
The example below illustrates the pan() method in p5.js:
Online editor: https://editor.p5js.org/