FSEM 131
Lab 3 |
Repetition and Gradient
|
I would like you to work in pair. The pair of three is allowed as long as this team make sure nobody is left alone!
To review the lecture material refer to the references page on for loop and color mode.
1. [2 pts] Consider the following code that draws many lines. There are 13 calls to the line function: observe the parameters that stay the same and the ones that change.
Write a program called manyLinesLoop.pde
that produces the same
output using a for loop. Only 3 statements are needed in your program.
2. [4 pts] Write a program manyLinesGrid.pde
that uses a for loop
to create an output similar to the image below.
- The application window is 200 pixels wide and 200 pixels high.
- The lines are separated by 10 pixels in each direction: horizontal and vertical.
- The padding (space around the grid) is 20 pixels on all the sides.
3. [2 pts] Write a program ellipseLoop.pde
that creates an output similar to the image below.
- The application window is 260 X 260 pixels.
- The background is white.
- The circles are centered in the window.
- The smaller circle is 40 by 40.
- The circles are separated by 20 pixels.
4. [2 pts] Consider the following code that creates a rainbow gradient as shown below.
Write a program ellipseRainbow.pde
that creates an output similar to the image below.
- The application window is 260 X 260 pixels.
- The background is white.
- The rainbow is centered in the window.
- Its radius is 255 pixels.
Bonus Write a program to create a gradient similar to the one shown in
the following image.
Once you have successfully made a monochrome gradient change the gradient to color (red or blue or green for example).