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);```

``` 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; } ```