CS 100 Spring 2014
Lab 5 |
Loop II
|
Using the Processing language/environment develop the following three programs.
Each program contains at least one loop: explicit or implicit.
1. [3 pts] A sketch named immediateloop
that prints on the console 20 times
a random number (whose value is in the range 0-255) as shown below. Reload the page to rerun the program.
2. [3 pts] A sketch named drawloop
that uses the draw
function,
which is continuously executed. Inspired from the previous program make some graphics calls
to produce a similar animation.
3. [4 pts] A sketch palette
that creates an output similar to this image.
Hint: The colors are assigned randomely. Another run of the program will produce different colors.
How can you assure that no random color is too close to the background white?
Bonus Write a sketch that produces a neat pattern/animation.
For inspiration read p. 92--104 of the textbook: you will learn beyond what we covered
in class.