Images challenge gallery

Below are some images to give you a workout using loops and if statements.

Your goal is to write functions in the images-challenge environment that create something like each of these images. However do not simply write a bunch of calls to drawing functions like drawFilledCircle. Your functions should contain only one call to any given drawing function in the body of a loop that does the rest of the work.

Another thing you should do (and which I will be looking for when I review your code) is to develop your code incrementally. Write a simple version of the function that does some part of what you need and then build from there. Or if you can write the function all in one go on your first try, then try to simplify or otherwise improve your code.

A couple functions that might come in handy are a few more from Math. Math.floor takes a single numeric argument and returns the value rounded down to the nearest whole number. And Math.random takes no arguments and returns a random number (pseudo-random, technically) between 0, inclusive, and 1, exclusive.

Line of circles

The function should take a single argument that allows the caller to specify the size of the circles drawn. It should then draw as many as fit across the width of the canvas.

Line of circles, alternating

Like the previous function, this function should take a single argument that allows the caller to specify the size of the circles drawn. It should then draw as many as fit across the width of the canvas, alternating between two colors.

Concentric circles

The function should take a single argument that specifies how many concentric circles to draw. It should then draw the largest circle to just fit in the canvas and the rest evenly spaced.

Checker board

The function should take a single argument, `n`, that specifies the number of squares on each side of a checkeboard and should draw an n-by-n checker board.

Not really curved

The function should take a single argument that specifies the number of lines to draw.

Fill with circles

The function should take a single argument that specifies the size of the circles and should then fill the canvas with as many as fit.

Fill with circles randomly filled

The function should take two arguments: the first specifies the size of the circles and the second the probability that any given circle is drawn filled in. For instance this image was creted with a circle radius of 17 and a probability of 0.23. You will need to use the function Math.random() which returns a random number from 0.0 to just below 1.0 each time it is called.

Square of circles

The function should take a single argument that specifies the size of the circles and should then draw the square made up of circles of that size.