<Video from Jan 30th will show up here>
function setup() {
createCanvas(400,400);
}
function draw() {
background(220);
}
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.
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.
The following are basic descriptions of 2D shape drawing functions. Note that arguments in brackets [ ] are optional. Also note that this is not a complete description of each function, many of these functions have different parameters and modes (not described here) that can be used for additional options. Check out P5 reference for more info
point(x,y)
square(x, y, s)
rect(x, y, width, [height])
ellipse(x, y, w, [h])
arc(x, y, w, h, start, stop, [either CHORD, PIE or OPEN (Optional)])
quad(x1, y1, x2, y2, x3, y3, x4, y4)
line(x1, y1, x2, y2)