Assignment
🎲 Mathematical Drawing
Let’s use what we’ve learned about variables and math to create a drawing in Processing!
For each question, leave a comment stating what code belongs to which question pls pls
At this point, you could assume that I’ll be changing the size of your canvas as I mark your work…
/* This code draws ellipses of increasing size. The center position of the first ellipse is specified, along with an x-offset value representing the horizontal distance(in pixels) between the center of one ellipse to the center of the next. The width (and height) of the first ellipse is specified. Subsequent ellipses maintain the same width but double in height each time. */
// Start position and size for first ellipse startX = 100 int startY = 350; int size = 75;
// Distance between ellipses int offSet= 75;
// Draw ellipse #1 ellipse(startX, startY, size, size);
//Adjust size and location of the 2nd ellipse startX = startX + offset; // IncreaseHeight is used to make ellipses of increasing size int increaseHeight = 2; ellipse(startX, startY, size, increaseHeight*size);
// Adjust size and location of the remaining ellipses startX = startX + offset; elipse(startX, startY, size, increaseHeight*size); startX = startX + offset; increaseHeight = 3; ellipse(startX, startY, increaseHeight*size); |
Code tracing means that you pretend that you are the computer. Walk through the code, line by line. Figure out the values of each variable, and think about what will happen by that line of code. You can also add print statements in between the lines to see what is inside the variables. Are these the values you expect to see? If not, what do you expect, and how can you modify the code to produce the desired result? Use these strategies to fix the given code so that it produces the intended results (as outlined in the comments). |
Before submitting your work, test your work a couple times with different sized canvases, just to make sure it always works!