#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
UNSW Indigenous pre-program 2023

A number of simple routines for drawing 

Author: Chun Tung Chou, UNSW 
"""

import matplotlib.pyplot as plt 

def draw_line(x0,y0,x1,y1):
    plt.plot([x0,x1],[y0,y1],'b-')

def start(x=0,y=0,direc=0):

    global x_current_global
    global y_current_global
    global direction_global 
    x_current_global = x
    y_current_global = y
    direction_global = direc 

def turn(angle):
    # global direction_global
    global direction_global 
    direction_global += angle 
        
def move(length):
    import math

    global x_current_global
    global y_current_global    
    global direction_global 
    x0 = x_current_global
    y0 = y_current_global
    x1 = x0 + length * math.cos(math.radians(direction_global))
    y1 = y0 + length * math.sin(math.radians(direction_global))
    plt.plot([x0,x1],[y0,y1],'b-')
    
    x_current_global = x1
    y_current_global = y1
    
   