Create a new sketch called lab05_Challenge01.

Enter the following starting code into your sketch (you shouldn’t need to make any changes to these methods for this challenge):
void setup()
{
size(400,400);
noStroke();
}
void draw()
{
}
Write a mousePressed
method that has one line of code in it. This line of code should be a call to the drawTarget
method (you will write this next), passing the values 3 and 150 as actual parameters.
Now for the challenge…write a method called drawTarget
that returns no data, but takes two paramters of type int
.
The only code in this method is a for loop. The loop will execute enough times to draw the number of circles required (determined by size).
Note: remember that the solution is available on the next tab, if you need to look at it.
Now that you have the code drawing a target with 3 circles, test it so that you can easily draw targets with 6 circles etc. You should only need to change the actual parameter passed in the drawTarget
method (and possibly the gray
value variant).