# Lesson 4.1

## For example, if we wanted to make many circles starting at x = 0 and covering the canvas horizontally, we could write ## We have control over the initial value of x, and could extend our control by limiting how long we increment x with some conditional statement. For example, we could start at x = 50 and stop at x = 200 with the following code. ## The while loop has the same syntax as an if conditional statement. ## Means something very similar to ## How would we draw a set of circles using the while loop? ## Since the while loop does not rely on the looping feature of the draw() function, we could place the code in setup() and achieve the same result. ## It also has the same 4 parts, but they are written in a different order. The syntax is ## Here is the previous code using a for loop. ## It is in general better to make variables local as compared to global to avoid unintentional assignments. Here is the for loop with the variable x as part of the loop and local to the draw() function. ## Exercise 4.1a: Using only setup() , (without using the draw() to loop) place 500 small circles randomly on the canvas. ## Exercise 4.1b: Using only setup() , (without using the draw() to loop) place a grid with lines 10 pixels apart on the canvas. ## Exercise 4.1c: Using only setup() , (without using the draw() to loop)place 12 circles spaced like the numbers on a clock, from 1-12, on the canvas. ## Exercise 4.1d: Using only setup() , (without using the draw() to loop) create the following on the canvas. 