Lab 9ΒΆ
In this lab, you will be practicing with loops and functions.
ExpectationsΒΆ
We are expecting you to commit your work often with useful commit messages. This is helpful for you so that there are regular commits that demonstrate your progress. In case you forget to push your final commits before the deadline, at least you will get partial marks.
This means that you should commit and push your changes to the repository at least FIVE times as you work this lab (more is recommended). Repositories that have very few commits will be flagged for careful scrutiny and review, and you will definitely lose marks for this!
For each question in this assignment, you need to do the following:
Download the starter code.
Run the starter code and observe the output.
Fill in the missing code as per the instructions given in the starter code. These instructions are written as comments that start with βREQβ.
Q1.Bouncing Spider WebΒΆ
In class, we created a simple animation of a bouncing ball. In this question, we will replace the ball with a spider-web-like shape similar to the one in the figure. You must use loops to draw the lines and circles.

Marking Requirements:ΒΆ
This question is worth 8 marks distributed as follows:
+4 for drawing many circles.
+4 for drawing many lines.
Up to +3 bonus marks for drawing a colourful spider-web (different colors for circles and lines).

Q2. SuperformulaΒΆ
A supershape is a complex shape that can be found in nature. It can be described using the superformula below:

Where π is the distance between a point on the shape and its center. Different values of a, b, m1, m2, n1, n2, and n3 result in different shapes: see the two examples below. More examples can be found here.

A supershape may be created in Processing as follows: write a loop where π is the loop counter that changes from 0 to a 2Ο with a very small increment. For each new value of π, compute π using the superformula above. Then, use π to compute the position of a point on the shape using the circleβs polar equations: π₯=π ππππβ πβ cosπ and π¦=π ππππβ πβ sinπ, where scale is the size of the shape (e.g. above shapes were produced using π ππππ=100) In this question, you are required to complete the missing code in the given starter code to produce two concentric supershapes similar to the output below.
Hint: You will need to use the built in Processing functions abs(), sin(), and pow() for your computations.
Marking Guide:ΒΆ
This question is worth 12 marks distributed as follows:
+4 for appropriate loop structure and values
+4 for correct computation of r
+1 for correct computation of x,y
+4 for using x,y, and r to draw the shape
+2 for drawing the red supershape (REQ2)

Up to +2 bonus marks for gradually changing the color of each point on the shape as follows:

Submission InstructionsΒΆ
For this lab, you need to do the following:
Complete Q1 and Q2 as described above.
Submit your repo URL to Canvas before the deadline (we will mark the last commit before the deadline)