# Kitchen with the range in the hearth: an old dining room, 14'1" x 20'4", made into a kitchen for its
# owner, drawn from her plan in feet with the sizes written in inches (i) and the library's parts in cm (c).
# The centre wall and the chimney stay: the 36 in range sits in the hearth, the sink run is south of it,
# the fridge and two 36 in hutches are on the centre wall, a 32 x 96 island in the middle, a bench under
# the north window with a 72 x 47 table, pocket doors to the living room. Checked: the aisles round the
# island (40-44 in) and the fridge-to-sink line, which clips the island's trash end. The south wall is
# cut low to look in. x: 0 = centre wall, 169 = east wall; y: 0 = the pocket-door wall, 244 = north wall.
units("ft")
i = 1 / 12
c = 30.48
H = 108
plaster = "#f1eee8"
fronts, top, isl = "#e8e4dc", "#9fa3a4", "#71807b"
CH = 91

def wall(x0, y0, x1, y1, z0=0, z1=H, name="wall"):
    return box((x1 - x0) * i, (y1 - y0) * i, (z1 - z0) * i, at=(x0 * i, y0 * i, z0 * i), name=name, color=plaster)

box(181 * i, 296 * i, 0.1, at=(-6 * i, -46 * i, -0.1), name="floor", color="oak planks")
# centre wall (west): the stair hall opening at the south end, the pantry doorway at the north end
wall(-6, 39, 0, 208, name="centre wall")
wall(-6, 0, 0, 39, 82, H, name="over the stair hall opening")
wall(-6, 208, 0, 244, 82, H, name="over the pantry doorway")
# north wall: the back door, the window over the bench
wall(-6, 244, 9, 250, name="north wall, west end")
wall(9, 244, 45, 250, 82, H, name="over the back door")
north = wall(45, 244, 169, 250, name="north wall")
box(36 * i, 2 * i, 81 * i, at=(9 * i, 246 * i, 0), name="back door", color="#b9a888")
window(w=185, h=137, panes=3, at=(75 * i, 244.5 * i, 38 * i), wall=north)
# east wall: a window by the table, the chimney with the range in the hearth, the window over the sink
east = wall(169, -6, 175, 250, name="east wall")
window(w=79, h=137, panes=1, at=(169.5 * i, 176 * i, 36 * i), turn=90, wall=east)
window(w=79, h=107, panes=1, at=(169.5 * i, 36 * i, 42 * i), turn=90, wall=east)
# south wall with the pocket doors, cut low to see in
wall(-6, -6, 43, 0, 0, 40, name="south wall (cut)")
wall(116, -6, 169, 0, 0, 40, name="south wall (cut) 2")

# ---- the hearth: brick piers and the breast over, the 36 in range between ----
breast = box(26 * i, 13 * i, H * i, at=(143 * i, 88 * i, 0)) + box(26 * i, 13 * i, H * i, at=(143 * i, 137 * i, 0)) + box(26 * i, 36 * i, (H - 66) * i, at=(143 * i, 101 * i, 66 * i))
breast.name = "chimney breast"
breast.paint("#b98a72 brick")
base_unit(w=91, d=61, h=CH, kind="hob_oven", color=fronts, top=top, at=(144.6 * i, 101.1 * i, 0), turn=270)

# ---- east run south of the hearth: corner filler | dishwasher 24 | sink | dishwasher 18 ----
box(24 * i, 10 * i, (CH - 4) / c, at=(145 * i, 0, 0), name="corner filler", color=fronts)
box(25 * i, 10 * i, 4 / c, at=(144 * i, 0, (CH - 4) / c), name="corner top", color=top)
y = 10
for w, kind in [(61, "dishwasher"), (91, "sink"), (46, "dishwasher")]:
    u = base_unit(w=w, d=61, h=CH, kind=kind, color=fronts, top=top, at=(140 * i, y * i, 0), turn=270)
    u.move(169 * i - u.max[0], 0, 0)
    y = y + w / 2.54

# ---- centre wall: fridge by the stair hall, two 36 in hutches ----
fr = fridge(w=91, d=75, h=178, at=(0, 45 * i, 0), turn=90)
tall_unit(w=91, d=66, h=213, kind="larder", color=fronts, at=(0, 84 * i, 0), turn=90)
tall_unit(w=91, d=66, h=213, kind="larder", color=fronts, at=(0, (84 + 91 / 2.54) * i, 0), turn=90)

# ---- the island, 32 x 96 top: trash | 36 | 36, fronts to the range side ----
y = 43
for w, kind in [(61, "pan_drawers"), (91, "drawers"), (91, "doors")]:
    base_unit(w=w, d=61, h=CH, kind=kind, worktop=False, color=isl, at=(76 * i, y * i, 0), turn=90)
    y = y + w / 2.54
box(32 * i, 96 * i, 4 / c, at=(69 * i, 43 * i, (CH - 4) / c), name="island top", color=top)

# ---- the bench under the window, the table 72 x 47, two chairs ----
box(114 * i, 19 * i, 18 * i, at=(55 * i, 225 * i, 0), name="bench", color="oak")
box(114 * i, 3 * i, 16 * i, at=(55 * i, 241 * i, 18 * i), name="bench back", color="oak")
tt = box(72 * i, 47 * i, 1.5 * i, at=(75 * i, 183 * i, 28.5 * i), name="table 72 x 47", color="oak")
for x in [86, 133]:
    box(3 * i, 24 * i, 28.5 * i, at=(x * i, 190 * i, 0), name="table leg", color="oak")
for x in [86, 121]:
    chair(w=45, d=50, at=(x * i, 164 * i, 0), turn=180)

# ---- the fridge-to-sink line, drawn at counter height across the island ----
fx, fy = fr.max[0] / i, 63
sx, sy = 143, 10 + 61 / 2.54 + 91 / 2.54 / 2

# ---- notes: the aisles and the line ----
dim((27 * i, 150 * i, 0), (69 * i, 150 * i, 0), offset=0.01, text="43\"")
dim((101 * i, 110 * i, 0), (143 * i, 110 * i, 0), offset=0.01, text="42\"")
dim((fx * i, 70 * i, 0), (69 * i, 70 * i, 0), offset=0.01, text="40\"")
dim((85 * i, 139 * i, 0), (85 * i, 183 * i, 0), offset=0.01, text="44\"")
dim((85 * i, 0, 0), (85 * i, 43 * i, 0), offset=0.01, text="43\"")
dim((fx * i, fy * i, 37 * i), (sx * i, sy * i, 37 * i), offset=0.01, text="fridge to sink")
label("range in the hearth", at=(190 * i, 119 * i, 100 * i), to=(156 * i, 119 * i, 66 * i))
label("hutches", at=(-22 * i, 120 * i, 95 * i), to=(13 * i, 120 * i, 84 * i))
label("fridge", at=(-22 * i, 63 * i, 80 * i), to=(14 * i, 63 * i, 70 * i))
label("bench + table 72 x 47", at=(112 * i, 206 * i, 34 * i))
label("living room (pocket doors)", at=(80 * i, -30 * i, 4 * i))
label("stair hall", at=(-28 * i, 18 * i, 30 * i))
