# Kitchen with an island and a table for eight: the living-kitchen of a new-build flat, 5.63 m wide, in
# metres. An L kitchen runs 3.87 m along the right wall and turns along the shower-room wall (tall fridge
# and larder units at its end); a 170 x 90 island with three stools and a 170 x 90 table in line with it
# seat eight (5 chairs + 3 stools). With no cellar, a 160 x 40 tall cupboard (in orange, proposed) goes on
# the left wall between the table and the sitting area, which takes the 3.29 m wide part beyond.
# Checked: 1.02 and 0.97 m round the island, 1.35 m to the windows. The walls are cut at 1 m, the window
# wall at 0.3 m to look in. x: 0 = left wall; y: 0 = the window wall.
units("m")
WALL, CAB, NEW, WH, GREY, GLASS, TOP = "#f1eee8", "#e8e4dc", "#f2a34b", "#f4f2ee", "#7d8590", "#9ec3d6", "#c9a27a"

def wall(x0, y0, x1, y1, h, name="wall"):
    return box(x1 - x0, y1 - y0, h, at=(x0, y0, 0), name=name, color=WALL)

def door_in(x, y, turn, w, open, hinge, swing, color):
    t = door(w=w, h=215, turn=turn, open=open, hinge=hinge, swing=swing, at=(0, 0, 0))
    fx, fy = t.part("frame top").min[0], t.part("frame top").min[1]
    t.delete()
    return door(w=w, h=215, turn=turn, open=open, hinge=hinge, swing=swing, color=color, at=(x - fx, y - fy, 0))

# floor: the living-kitchen 5.63 wide up to the shower room, then the 3.29 wide part up to the hall
box(5.63, 3.87, 0.05, at=(0, 0, -0.05), name="floor", color="oak planks")
box(3.29, 3.88, 0.05, at=(0, 3.87, -0.05), name="floor", color="oak planks")
# walls (cut at 1 m, the window wall at 0.3 m to see in)
wall(-0.2, 0, 0, 7.75, 1.0, "left wall")
wall(5.63, 0, 5.83, 3.87, 1.0, "right wall")
wall(3.29, 3.87, 5.83, 3.97, 1.0, "shower room wall")
wall(3.29, 3.97, 3.39, 7.75, 1.0, "shower room wall")
wall(-0.2, -0.2, 0.02, 0, 0.3, "window wall")
wall(2.84, -0.2, 3.71, 0, 0.3, "window wall")
wall(4.87, -0.2, 5.83, 0, 0.3, "window wall")
box(1.95, 0.2, 0.03, at=(0.02, -0.2, 0), name="French window, fixed part", color=GLASS)
box(1.16, 0.2, 0.3, at=(3.71, -0.2, 0), name="window sill wall", color=WALL)
box(1.16, 0.2, 0.03, at=(3.71, -0.2, 0.3), name="window", color=GLASS)
door_in(1.97, -0.15, 0, 87, 90, "left", "in", WH)

# the L kitchen: along the right wall (3.87) and against the shower room
for y, kind in ((0.07, "drawers"), (0.67, "drawers"), (1.27, "hob_oven"), (1.87, "dishwasher")):
    base_unit(w=60, d=60, h=91, kind=kind, at=(5.03, y, 0), turn=270)
base_unit(w=80, d=60, h=91, kind="sink", at=(5.03, 2.47, 0), turn=270)
box(0.6, 0.6, 0.87, at=(5.03, 3.27, 0), name="corner unit", color=CAB)
box(0.6, 0.6, 0.04, at=(5.03, 3.27, 0.87), name="corner top", color=TOP)
tall_unit(w=60, d=60, h=220, kind="fridge", at=(3.39, 3.27, 0))
tall_unit(w=60, d=60, h=220, kind="larder", at=(3.99, 3.27, 0))
base_unit(w=44, d=60, h=91, kind="drawers", at=(4.59, 3.27, 0))
wall_units(w=180, d=35, h=70, lift=145, at=(5.28, 0.67, 1.45), turn=270)

# the island (170 x 90, storage on the kitchen side) and the table in line with it
for x, w in ((2.3, 60), (2.9, 60), (3.5, 50)):
    base_unit(w=w, d=60, h=91, kind="drawers", worktop=False, at=(x, 1.65, 0), turn=180)
box(1.7, 0.9, 0.04, at=(2.3, 1.35, 0.87), name="island top", color=TOP)
for x in (2.35, 2.9, 3.45):
    bar_stool(w=40, h=65, at=(x, 0.85, 0))
dining_table(w=170, d=90, h=75, at=(0.6, 1.35, 0))
for x in (0.75, 1.45):
    chair(at=(x, 0.95, 0), turn=180)
    chair(at=(x, 2.15, 0))
chair(at=(0.1, 1.575, 0), turn=90)

# storage with no cellar: a tall cupboard on the left wall between the table and the sitting area
box(0.4, 1.6, 2.2, at=(0, 2.75, 0), name="cupboard 160 x 40", color=NEW)

# the sitting area in the 3.29 wide part
sofa(w=220, d=92, color=GREY, at=(0, 4.6, 0), turn=90)
coffee_table(w=100, d=50, at=(1.25, 5.2, 0), turn=90)
tv_unit(w=160, d=40, at=(2.89, 4.9, 0), turn=270)

dim((2.6, 2.25, 0), (2.6, 3.27, 0), offset=0, text="1.02")
dim((4.0, 2.6, 0), (4.97, 2.6, 0), offset=0, text="0.97")
dim((4.3, 0, 0), (4.3, 1.35, 0), offset=0, text="1.35")
dim((0.6, 1.0, 0.8), (4.0, 1.0, 0.8), offset=0, text="3.40")
label("seats 8: 5 chairs + 3 stools", at=(-1.3, 0.9, 0))
label("island 170 x 90", at=(3.45, 1.75, 0.95))
label("table 170 x 90", at=(1.45, 1.8, 0.8))
label("cupboard 160 x 40", at=(0.2, 3.55, 2.25))
label("French window", at=(2.4, -0.7, 0))
label("shower room", at=(4.7, 5.3, 1.0))
label("hall", at=(1.6, 8.2, 0))
