# Children's room for four: a 3.73 x 3.52 m room laid out for its owner, in metres. Two bunk beds
# stand along the side walls, their heads to the French window, with 1.77 m between them; a 2.40 m
# wardrobe takes the door wall, 0.82 m from the bunks' feet. Each bunk is built from boxes by a
# function. The door wall and the left wall are cut at 0.3 m to look in. The dimensions are the
# clearances that were checked.
units("m")
W = "#f3f1ec"
WOOD = "#d9b88a"
LINEN = "#e6eef2"
H = 2.7
box(3.73, 3.52, 0.05, at=(0, 0, -0.05), name="floor", color="oak planks")
# walls: the window wall and the right wall whole, the door wall and the left wall cut low to see in
top = box(3.97, 0.12, H, at=(-0.12, 3.52, 0), name="window wall", color=W)
window(w=95, h=240, panes=1, at=(1.75, 3.52, 0.02), wall=top)
box(0.12, 3.64, H, at=(3.73, -0.12, 0), name="right wall", color=W)
box(0.12, 3.52, 0.3, at=(-0.12, 0, 0), name="left wall (cut)", color=W)
box(0.32, 0.12, 0.3, at=(-0.12, -0.12, 0), name="door wall (cut)", color=W)
box(2.73, 0.12, 0.3, at=(1.00, -0.12, 0), name="door wall (cut) 2", color=W)
box(0.80, 0.12, 0.02, at=(0.20, -0.12, 0), name="door 80, threshold", color="#9aa0a6")
box(0.04, 0.80, 2.05, at=(0.20, 0, 0), name="door, open", color="#e8e4dc")

def bunk(x, y, rail_x, name):
    for px, py in [(x, y), (x + 0.93, y), (x, y + 2.01), (x + 0.93, y + 2.01)]:
        box(0.05, 0.05, 1.75, at=(px, py, 0), name=name + ", post", color=WOOD)
    for z0 in [0.25, 1.25]:
        box(0.88, 1.96, 0.05, at=(x + 0.05, y + 0.05, z0), name=name + ", slats", color=WOOD)
        box(0.88, 1.96, 0.16, at=(x + 0.05, y + 0.05, z0 + 0.05), name=name + ", mattress", color=LINEN)
        box(0.60, 0.35, 0.08, at=(x + 0.19, y + 1.60, z0 + 0.21), name=name + ", pillow", color="#ffffff")
    box(0.03, 1.41, 0.30, at=(rail_x, y + 0.60, 1.46), name=name + ", guard rail", color=WOOD)
    box(0.88, 0.03, 0.30, at=(x + 0.05, y + 0.02, 1.46), name=name + ", foot rail", color=WOOD)
    for lx in [x + 0.28, x + 0.67]:
        box(0.03, 0.03, 1.50, at=(lx, y - 0.03, 0), name=name + ", ladder", color=WOOD)
    for lz in [0.30, 0.60, 0.90, 1.20]:
        box(0.36, 0.03, 0.03, at=(x + 0.31, y - 0.03, lz), name=name + ", rung", color=WOOD)

bunk(0.00, 1.45, 0.95, "left bunk")
bunk(2.75, 1.45, 2.75, "right bunk")
wardrobe(w=240, d=60, h=240, at=(1.33, 0, 0), turn=180)

dim((0.98, 2.4, 0), (2.75, 2.4, 0), offset=0, text="1.77")
dim((3.2, 0.60, 0), (3.2, 1.42, 0), offset=0, text="0.82")
dim((0, -1.0, 0), (3.73, -1.0, 0), offset=0, text="3.73")
dim((-0.55, 0, 0), (-0.55, 3.52, 0), offset=0, text="3.52")
label("2 bunk beds = 4 beds", at=(1.5, 1.15, 0))
label("wardrobe 240 cm", at=(2.5, -0.55, 0))
label("door 80", at=(0.6, -0.55, 0))
label("French window 95", at=(2.2, 3.1, 0))
