The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.

For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.

See image here: https://i.imgur.com/B7YbTbZ.png

Task

 Create a function (or subroutine) that uses turtle graphics to draw a house of a specified size as described above. Optionally make it lovely by adding details such as, for example, doors and windows.
 Create a function (or subroutine) that takes a list (array, vector) of non-negative numbers and draws a bar chart from them, scaled to fit exactly in a square of a specified size. The enclosing square need not be drawn. 
 Both functions should return the turtle to the location it was at and facing in the same direction as it was immediately before the function was executed. 
using Luxor, Colors
 
function house(🐢, x, y, siz)
    oldorientation = 🐢.orientation
    xpos, ypos = 🐢.xpos, 🐢.ypos
    # house wall
    Reposition(🐢, x, y)
    Rectangle(🐢, siz, siz)
    # roof
    Reposition(🐢, x - siz / 2, y -  siz / 2)
    Turn(🐢, -60)
    Forward(🐢, siz)
    Turn(🐢, 120)
    Forward(🐢, siz)
    # turtle_demo
    doorheight, doorwidth = siz / 2, siz / 4
    Pencolor(🐢, 0, 0, 0)
    Reposition(🐢, x, y + doorheight / 2)
    Rectangle(🐢, doorwidth, doorheight)
    # window
    windowheight, windowwidth = siz /3, siz / 4
    Reposition(🐢, x + siz / 4, y - siz / 4)
    Rectangle(🐢, windowwidth, windowheight)
    Reposition(🐢, x - siz / 4, y - siz / 4)
    Rectangle(🐢, windowwidth, windowheight)
    Orientation(🐢, oldorientation)
    Reposition(🐢, xpos, ypos)
end
 
function barchart(🐢, data, x, y, siz)
    oldorientation = 🐢.orientation
    xpos, ypos = 🐢.xpos, 🐢.ypos
    maxdata = maximum(data)
    # scale to fit within a square with sides `siz` and draw bars of chart
    barwidth = siz / length(data)
    Pencolor(🐢, 1.0, 0.0, 0.5)
    Reposition(🐢, x, y)
    for n in data  # draw each bar in chart
        barheight = n * siz / maxdata
        Reposition(🐢, x, y - barheight / 2)
        Rectangle(🐢, barwidth, barheight)
        x += barwidth
    end
    Orientation(🐢, oldorientation)
    Reposition(🐢, xpos, ypos)
end
 
function testturtle(width = 400, height = 600)
    dra = Drawing(600, 400, "turtle_demo.png")
    origin()
    background("midnightblue")
    🐢 = Turtle()
    Pencolor(🐢, "cyan")
    Penwidth(🐢, 1.5)
    house(🐢, -width / 3, height / 7, width / 2)
    barchart(🐢, [15, 10, 50, 35, 20], width / 8, height / 8, width / 2)
    finish()
end
 
testturtle()
 