Exercise 02

There are two main functions (blocks of code) commonly used in a P5js sketch: Setup and Draw.

The setup function runs only once and the draw function loops indefinitely.

function setup() {
// create a canvas the size of the browser window
createCanvas(windowWidth, windowHeight);
} // the draw() function is called many times per second // it's very useful for animating objects function draw() { // background function erases the screen with a colour background(255, 204, 0); line(random(100), random(100), random(100), random(100)); }

Leave a Reply

Your email address will not be published. Required fields are marked *