Make a window that is 200 by 200 with a white background.
Set the frame rate to 15 frames per second.
Starting at the mouseX and mouseY
coordinates, draw a horizontal row of squares. Each square is
10 pixels by 10 pixels, and there are 10 pixels of space between
the squares. Draw as many squares as will fit in the sketch window
(i.e., don’t just draw 15 squares and let the edge of the
window cut off the drawing). If your program works correctly,
there will never be a partial square at the right side of the screen.
You may make the squares any color you like. You must use a
while loop for this program. Save this sketch
with the name squares.
Extra credit: Use constrain() or an if
statement to make sure
that you never see a partial square at the bottom of the screen.
Make a window that is 200 by 200 with a white background.
Set the frame rate to 15 frames per second.
Your program will draw an “X” made of circles,
centered at
(mouseX, mouseY),
as shown in the diagram below at the left. Each square
in the diagram represents ten pixels. The gray circle
represents the mouse position. In your program, make all
the circles the same color (white is a reasonable choice).
You must may use either a while loop
or a for loop for this program. Save this sketch
with the name circles.
This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.
Extra challenge: change the color of each the circles to a random
color when the mouse moves. If the mouse doesn’t move, the circles
all stay the same color. Use an if statement to
make this happen.
The government of the fictional country of Alańeðia has hired you to design its new flag. Here are their requirements.
for or while loop
to draw each of the repeating elements.Save your sketch in a file named flag.
Zip up all the sketches into a zip file named
loops.zip and upload it.