Open In App

p5.js Constants and Structure Complete Reference

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

Like a variable created with let, const keyword to define a new variable. The difference in const variable declaration than others is that it cannot be reassigned. And the structure are the inbuilt function used while execution. The methods are mentioned below.

Constants

Description

HALF_PI It is a mathematical constant and its value is 1.57079632679489661923.
PI It is a mathematical constant with the value 3.14159265358979323846.
QUARTER_PI It is a mathematical constant with the value 0.7853982.
TAU It is a mathematical constant with the value 6.28318530717958647693.
TWO_PI It is a mathematical constant with the value 6.28318530717958647693.
DEGREES It converts a given radian measurement value to its corresponding value in degrees.
RADIANS It converts a given degree measurement value to its corresponding value in radians.

Structure

Description

setup() It is used to set the initial environment properties and load the media file.
draw() It executes the code inside the block until the program is stopped or noLoop() is called.
remove() It removes the element and deregister all listeners.
disableFriendlyErrors This property is used to turned off the friendly errors.
noLoop() It stops the program after executing the draw() function.
loop() It is used to call draw() function continuously.
isLooping() It verifies that the loop() function performed successfully.
redraw() It executes the code within draw() function one time.

Last Updated : 16 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads