For the first part of the recitation, I used the previous work I made in recitation 5 and try to add some interaction part. Basically, what I’m trying to do is to use keyboard and mouse to change the color of the background.
The following are the codes for this part.
Homework part:
I learned a lot about ellipseMode while trying to do the last step of keeping my circle in the canvas. Although it finally turn out that the mode does not work for this purpose, I still think these might be quite useful. But i need to be very careful when changing Modes since for each ellipseMode the parameters have different meanings.
Just to keep a reminder for myself:
Better keep the equation for changing variables at the end of the loop so the if-statement controlling extent of changing can be checked before the actual changing.
If mouseX & mouseY is used as inputs but defined under other names, it needs to be put into the loop or it only counts the first time where you placed the mouse.
pixelDensity(2); // is useful when the sharpness does not show up right
About ellipseMode:
The default mode is ellipseMode(CENTER), which interprets the first two parameters of ellipse() as the shape’s center point, while the third and fourth parameters are its width and height.
ellipseMode(RADIUS) also uses the first two parameters of ellipse() as the shape’s center point, but uses the third and fourth parameters to specify half of the shapes’s width and height.
ellipseMode(CORNER) interprets the first two parameters of ellipse() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.
ellipseMode(CORNERS) interprets the first two parameters of ellipse() as the location of one corner of the ellipse’s bounding box, and the third and fourth parameters as the location of the opposite corner.