Video from Dave’s review on Sep 13

GMT20230913-173439_Recording_1920x1080.mp4

Module 2 - Animation

https://docs.google.com/document/d/1nQQ6T7oSE1e7KPG0f7PIknI3Y2RFtCJtd5S55_-lQqE/edit

Basics

setup() happens once

draw() happens continuously, “in a loop”. So far we have not done anything that takes advantage of this getting called multiple times. We are doing the same thing every time so it is not noticeable we are looping. We need something that is varying over time in order to see changes. In this review, we will be doing things that vary over time.

When the background() command is run within the draw, not only does it display a background color, it also overwrites everything that was draw previously within your sketch. If you move the background() from the draw() to the setup() and you have things that change with each frame, you will notice that the past shapes that were drawn do not get erased by the sketch.

2.1 Variables

variable is an entity that stores values

mouseX and mouseY are system variables that contain the current position of the mouse

height and width are system variables that contain the current position of the mouse

mousePressed() - mousePressed function is a built in function that can be overwritten to contain your code whenever the mouse is clicked. By creating the mousePressed function, we can move background to the mousePressed() to clear out the canvas. Note, do not have more than one mousePressed() function in your code.

function mousePressed() {
	background(220); // clear out canvas when mouse pressed
}

2.2 Colors