"""CIT demo artwork, not a student's submitted work.

Run with Python 3 and Tk support: python demo-space-scene.py
Change STAR_SIZE or SHIP_X, then run again to compare the picture.
"""
import turtle

STAR_SIZE = 22
SHIP_X = 90
BACKGROUND = "#0c2038"
STAR_COLOR = "#f2d898"
SHIP_COLOR = "#b9d7ef"
STARS = [(-270, 150), (-130, 90), (-20, 185), (130, 135), (265, 185)]


def move_pen(pen, x, y):
    pen.penup()
    pen.goto(x, y)
    pen.setheading(0)
    pen.pendown()


def draw_star(pen, x, y, size):
    move_pen(pen, x, y)
    pen.color(STAR_COLOR)
    for _ in range(5):
        pen.forward(size)
        pen.right(144)


def draw_ship(pen, x, y, size):
    move_pen(pen, x, y)
    pen.color(SHIP_COLOR)
    pen.begin_fill()
    for dx, dy in [(0, 1.6), (.5, 0), (.8, -.4), (0, -.15), (-.8, -.4), (-.5, 0)]:
        pen.goto(x + dx * size, y + dy * size)
    pen.goto(x, y)
    pen.end_fill()
    move_pen(pen, x, y + .7 * size)
    pen.dot(size * .35, BACKGROUND)


def main():
    screen = turtle.Screen()
    screen.setup(760, 540)
    screen.title("CIT demo | Space scene with functions")
    screen.bgcolor(BACKGROUND)
    pen = turtle.Turtle()
    pen.hideturtle()
    pen.speed(0)
    pen.width(2)
    for i, (x, y) in enumerate(STARS):
        draw_star(pen, x, y, STAR_SIZE + i * 4)
    draw_ship(pen, SHIP_X, -70, 65)
    move_pen(pen, -220, -110)
    pen.dot(100, "#6c9ab5")
    move_pen(pen, 0, -225)
    pen.color("#dbe7f3")
    pen.write("DEMO ARTWORK | Change a variable and compare", align="center", font=("Arial", 12, "normal"))
    screen.exitonclick()


if __name__ == "__main__":
    main()
