# Arup Guha
# 2/3/2020
# Sample Spirograph for COP 2930 Pair Program #1

import turtle
import math
import random

# Colors I will use.
colors = ["red","green","blue","orange","yellow", "purple"]

# Default stuff.
turtle.speed(0)
turtle.pencolor(colors[random.randint(0, len(colors)-1)])

# where I am.
x = 0
y = 0
r = 0
angle = 0
increasing = True

# Loop a bunch till stuff over laps.
for i in range(8000):

    # Update our radius.
    if increasing:
        r += 5
    else:
        r -= 5

    # Toggle increasing, also change color
    if r < 5:
        increasing = True
        turtle.pencolor(colors[random.randint(0, len(colors)-1)])

    # Same here.
    elif r > 300:
        increasing = False
        turtle.pencolor(colors[random.randint(0, len(colors)-1)])

    # New position.
    x = r*math.cos(angle)
    y = r*math.sin(angle)

    # New angle.
    angle += math.pi/180

    # Move me!
    turtle.setpos(x, y)
        
    

    
