Question 1:
In your own words, please explain the difference between having your for loop from Step 2 in setup() as opposed to in draw().
Having the for loop from Step 2 using the setup() function as opposed to in draw() makes the image only display once without repetition. In the draw() function, however, the loop is repeated over and over in an animation-like fashion unless another function such as noloop() is called.
Question 2:
What is the benefit of using arrays? How might you use arrays in a potential project?
The benefit of using arrays is that it allows you to assign values to different variables, which means that more information can be stored within a single array instead of creating separate variables to complete the same task. This could potentially be used within my final project to help design the code so that it is structured in a more uniform way, especially if one function contains multiple variables.
int[] posX = {200, 200, 175, 300}; int[] posY = {110, 150, 200, 300}; float[] colors = {random(255), random(255), random(255)}; void setup() { size(1000, 1000); } void draw() { float[] colors = {random(255), random(255), random(255), random(255), random(255)}; background(50); strokeWeight(10); //for ( int u = 0; u < posX.length-1; u++) { // stroke(0, 255, colors[u]); // line(posX[u], posY[u], posX[u+1], posY[u+1]); // } for (int i = 0; i<100; i++){ display(random(200), random(400), int(random(200))); } } void display(float x, float y, color c) { //Use these parameters to create your graphics fill(c); rect(x, y, 600, 700); ellipse(x, y, 200, 200); triangle(x, y, 200, 400, 300, 200); }