**Introduction to My Project**

My final project creates a different shape corresponding with the keys on the keyboard. If i press the “c” key it will create triangle and if i press the “z” key it will create a 26-sided shape with each shape inside of it, in order of decreasing number of sides. After I discovered how to do that I wanted to make it more interesting. I did this by implementing the arrow keys. If you press the up arrow it will make each layer outward have one more side and if you press the the down arrow it will make each layer outward have one less side.

**Samples of My ProjectÂ **

If you press the up arrow and then the “z” key, this will happen.

If you press the down arrow then the “z” key, this image will appear.

**How It Works**

To program the key codes to determine the number of sides, all I did was created an if statement and a series of else if statements. This is a sample of the “c” and “d” keys being programmed. The r, g, and b represents the colors so it can reset after each time you press a key. code:

`if (key == 'c') {`

n = 3;

r = 255;

g = 0;

b = 255;

background(255);

} else if (key == 'd') {

n = 4;

r = 255;

g = 0;

b = 255;

background(255);

In order to create the points that are used to create the shapes I used trigonometry, this is what it looks like. y = radius*sin(radians(theta)); x = radius*cos(radians(theta)); This sets x to the radius multiplied by the cosine of theta in radians and y to the radius multiplied by the sine of theta in radians The Most Challenging Part The most challenging part of my project was trying to figure out how to connect the the first pair of coordinates made to the last pair of coordinates made. How to do this was a mystery to me, after two days of thinking about it I came up with a solution. I would create the last set of coordinates first and make a line after the first pair of coordinates are made then make a line connecting the two pair of coordinates.

This is the code thatÂ I ended up working out.

float storx =radius*cos(radians(theta));

float story =radius*sin(radians(theta));

while (count < n) {

y = radius*sin(radians(theta));

x = radius*cos(radians(theta));

line(storx, story, x, y);

storx = x;

story = y;

}