#rand_angle_width_plus

import random
import sys
import os
import time
import turtle

t = turtle.Pen()

colors = ["red","orange","yellow","green","blue","indigo","violet"]

t.pensize(10)

t.fd(100)

def random_pencolor():
    num = random.randrange(0,6)
    col = colors[num]
    return (col)

def rand_x():
    x = random.randrange(10,300)
    if (x%2 == 0): x = -x
    return(x)

def rand_y():
    y = random.randrange(10,200)
    if (y%2 == 0): y = -y
    return(y)

def rand_width():
    width = random.randrange(3,30)
    return(width)

def rand_angle():
    angle = random.randrange(0,360)
    return(angle)

def rand_dist():
    dist = random.randrange(3,150)
    return(dist)

def stay_on_screen():
    t_pos_xy = t.position()
    
    x = t_pos_xy[0]
    y = t_pos_xy[1]
    if ( x < -300): x = x+50
    if ( x >  300): x = x - 50
    if (y <  -200 ): y = y + 50
    if (y >   200):  y = y - 50
    pos = (x,y)
    t.goto(pos)

def rand_left_right():
    num = random.randrange(0,100)
    if (num >= 50) : return ("r")
    else: return("l")
    

for count_1 in range(50):
    t.pensize(rand_width())
    t.pencolor(random_pencolor())
    t.fd(rand_dist())
    if (rand_left_right() == "l"): t.lt(rand_angle())
    else: t.rt(rand_angle())
    stay_on_screen()
    
