from pylab import *
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import random
import time
#from scipy.misc import imread
#from scipy.misc import imresize
import matplotlib.image as mpimg
import os
from numpy import genfromtxt
import Image
from  scipy import ndimage
import cPickle




def draw_line(canvas, start_pt, dir_vec, length):
    '''Note: for P2, you should be using the line-drawing function provided,
    which is faster, though you might use the ideas here to set up the starting 
    and finishing point for that function'''
    
    '''This is outside the scope of this lecture, but note that the lines
    don't look so great. 
    See, e.g., here:
    https://courses.engr.illinois.edu/ece390/archive/archive-f2000/mp/mp4/anti.html
    '''
    
    for i in range(length):
        cur_pt = (start_pt+i*dir_vec).astype(int32)
        canvas[cur_pt[0], cur_pt[1]] = 1

canvas = zeros((200, 200))
start_pt = array([100, 100])

N = 20
for i in range(N):
    theta = (float(i)/N)*(2*pi)
    u, v = cos(theta), sin(theta)
    length = 4*i
    draw_line(canvas, start_pt, array((u, v)), length)
    
imshow(canvas)
show()    