Remember: As you work on these steps with guidance from your teaching assistant, you should look toward your neighbor to see if they need help (or ask if you need help). You can collaborate in lab during these activities!
In this lab, you will
Here is a link to the p5.js template we are using to create the program.
NOTE: Unlike previous labs, you will create just one program in this lab, modifying it as you go along through the exercises. After each exercise, you will make a copy of the lab-05 folder, with a different name, just in case you mess things up terribly. If so, you can go back to your prior working program.
Write a p5.js program that displays a yellow circle of diameter 25, rotating clockwise around the center of a 400 X 400 canvas at a distance of 50 from the center of the canvas.
Once you are done, you should see the circle rotating around the center, as shown by this snapshot:
BEFORE YOU START THIS STEP, SAVE A COPY OF YOUR CURRENT WORKING lab-05 FOLDER UNDER ANOTHER NAME (e.g. lab-05-partA) IN CASE YOU NEED TO START THIS PROBLEM AGAIN
Modify your sketch.js in the lab-05 folder so that the same picture is drawn but you draw the circle in a separate function called spinningCircle.
If you do this correctly, you should see the same drawing when you run the program as you had in part A.
BEFORE YOU START THIS STEP, SAVE A COPY OF YOUR CURRENT WORKING lab-05 FOLDER UNDER ANOTHER NAME (e.g. lab-05-partB) IN CASE YOU NEED TO START THIS PROBLEM AGAIN
Modify your draw function so that it draws three of these rotating patterns, centered around (100, 100), (300, 100) and (200, 300).
If you get this working correctly, you should see something like this snapshot:
BEFORE YOU START THIS STEP, SAVE A COPY OF YOUR CURRENT WORKING lab-05 FOLDER UNDER ANOTHER NAME (e.g. lab-05-partC) IN CASE YOU NEED TO START THIS PROBLEM AGAIN
Modify your program so that it draws a grid of 16 of these rotating circles. Use nested loops to solve this problem, rather than writing 16 separate function calls. Your solution should have just one function call used 16 times.
Here are the coordinates of the "origins" for each of the rotations:
(50, 50), (150, 50), (250, 50), (350, 50) (50, 150), (150, 150), (250, 150), (350, 150) (50, 250), (150, 250), (250, 250), (350, 250) (50, 350), (150, 350), (250, 350), (350, 350)
If you get this working correctly, you should see something like this snapshot:
BEFORE YOU START THIS STEP, SAVE A COPY OF YOUR CURRENT WORKING lab-05 FOLDER UNDER ANOTHER NAME (e.g. lab-05-partD) IN CASE YOU NEED TO START THIS PROBLEM AGAIN
Finaly modify your program so that it draws a grid of 16 of these rotating circles in a random color of these 8 colors:
black (0, 0, 0) red (255, 0, 0) green (0, 255, 0) blue (0, 0, 255) cyan (0, 255, 255) magenta (255, 0, 255) yellow (255, 255, 0) white (255, 255, 255)
All sixteen rotating patterns will be drawn with the same color. If you reload the page, some random color of these 8 is chosen to draw the patterns. Can you solve this without using if/else statements? Here are two sample runs of the program:
(Now you might need to use the rotate function.)