from livewires import *
begin_graphics()

def sedan(x,y):                                 # Draw a sedan.
    set_colour(Colour.red)
    move(x,y)
    draw(x,y+20)
    draw(x-20,y+20)
    draw(x-40,y+40)
    draw(x-100,y+40)
    draw(x-105,y+20)
    draw(x-120,y+20)
    draw(x-120,y)
    draw(x-100,y)
    move(x-80,y)
    draw(x-30,y)
    move(x-10,y)
    draw(x,y)
    set_colour(Colour.black)
    circle(x-90,y,7)
    circle(x-20,y,7)
    set_colour(Colour.blue)
    circle(x-90,y,10, endpoints=((x-80,y),(x-100,y)))
    circle(x-20,y,10, endpoints=((x-10,y),(x-30,y)))

def graph_axes(x,y):                            # Draw graph axes.
    set_colour(Colour.black)
    move(x-30,y-20)                             # Origin.
    text("(0,0)")
    move(x,y)                                   # x axis.
    draw(x+350,y)
    move(x+350,y-20)
    text("x")
    move(x,y)                                   # y axis.
    draw(x,y+200)
    move(x-20,y+200)
    text("y")

def sedan_coordinates(x,y,a,b):                 # Draw sedan co-ordinates.
                                                # x,y = false origin.
                                                # a,b = sedan relative position.
    c = x + a
    d = y + b
    set_colour(Colour.black)
    move(c,y)                                   # x co-ordinate of sedan.
    draw(c,y+5)
    move(c,y-20)
    text(a)
    move(x,d)                                   # y co-ordinate of sedan.
    draw(x+5,d)
    move(x-20,d)
    text(b)
    move(c-3,d-3)                               # (x,y) co-ordinates of sedan.
    draw(c+3,d+3)
    move(c+3,d-3)
    draw(c-3,d+3)
    move(c,d)
    text(("(" + str(a) + "," + str(b) + ")"))

def graph_sedan(x,y,a,b):
    sedan(x+a,y+b)
    sedan_coordinates(x,y,a,b)

def draw_graph(x,y):
    graph_axes(x,y)
    graph_sedan(x,y,130,20)

draw_graph(50,50)

sleep(10)
end_graphics()
