Floor plan in a light 3D view (cutaway): SVG, generator and projected room areas
Generated from the plan coordinates of the scanned floor plan (photo 20); the JSON holds the room polygons in the same projection for the interactive section. Draft for the planned section 'Interaktiver Grundriss' (STATUS §6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b3114cdfe3
commit
9b8a851ce9
3 files changed
+186
No files matched your search
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"viewBox": "0 46 869 344",
|
||||
"areas": {
|
||||
"terrasse": "78.0,159.0 130.0,159.0 160.0,288.0 108.0,288.0",
|
||||
"wohnen": "135.0,159.0 470.0,159.0 489.0,240.7 329.0,240.7 350.0,331.0 240.0,331.0 163.0,279.4",
|
||||
"kueche": "329.0,240.7 489.0,240.7 510.0,331.0 350.0,331.0",
|
||||
"diele": "470.0,159.0 618.0,159.0 637.0,240.7 489.0,240.7",
|
||||
"bad": "492.0,240.7 620.0,240.7 641.0,331.0 513.0,331.0",
|
||||
"schlafen": "627.0,197.7 799.0,197.7 830.0,331.0 645.0,331.0 628.0,257.9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 46 869 344" role="img" aria-label="Grundriss der Ferienwohnung in leichter 3D-Ansicht"><title>Grundriss der Ferienwohnung</title><polygon points="24.0,133.2 128.0,133.2 178.4,349.9 74.4,349.9" fill="#CFE3C1" stroke="#CFE3C1" stroke-width="0" stroke-linejoin="round"/><polygon points="78.0,159.0 130.0,159.0 160.0,288.0 108.0,288.0" fill="#C9976A" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="135.0,159.0 470.0,159.0 489.0,240.7 329.0,240.7 350.0,331.0 240.0,331.0 163.0,279.4" fill="#E7D2AD" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="329.0,240.7 489.0,240.7 510.0,331.0 350.0,331.0" fill="#E9E7E1" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="470.0,159.0 618.0,159.0 637.0,240.7 489.0,240.7" fill="#E9E7E1" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="492.0,240.7 620.0,240.7 641.0,331.0 513.0,331.0" fill="#DCEFF5" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><polygon points="627.0,197.7 799.0,197.7 830.0,331.0 645.0,331.0 628.0,257.9" fill="#EAD9BC" stroke="#B8B2A6" stroke-width="0.8" stroke-linejoin="round"/><path d="M84.0 159.0 L114.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M93.0 159.0 L123.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M102.0 159.0 L132.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M111.0 159.0 L141.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M120.0 159.0 L150.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M129.0 159.0 L159.0 288.0" stroke="#A97B52" stroke-width="0.8"/><path d="M331.4 242.4 L351.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M347.4 242.4 L367.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M363.4 242.4 L383.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M379.4 242.4 L399.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M395.4 242.4 L415.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M411.4 242.4 L431.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M427.4 242.4 L447.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M443.4 242.4 L463.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M459.4 242.4 L479.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M475.4 242.4 L495.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M331.4 242.4 L487.4 242.4" stroke="#CFCBC2" stroke-width="0.6"/><path d="M334.6 256.2 L490.6 256.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M337.8 269.9 L493.8 269.9" stroke="#CFCBC2" stroke-width="0.6"/><path d="M341.0 283.7 L497.0 283.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M344.2 297.5 L500.2 297.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M347.4 311.2 L503.4 311.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M350.6 325.0 L506.6 325.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M494.4 242.4 L514.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M510.4 242.4 L530.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M526.4 242.4 L546.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M542.4 242.4 L562.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M558.4 242.4 L578.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M574.4 242.4 L594.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M590.4 242.4 L610.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M606.4 242.4 L626.6 329.3" stroke="#CFCBC2" stroke-width="0.6"/><path d="M494.4 242.4 L618.4 242.4" stroke="#CFCBC2" stroke-width="0.6"/><path d="M497.6 256.2 L621.6 256.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M500.8 269.9 L624.8 269.9" stroke="#CFCBC2" stroke-width="0.6"/><path d="M504.0 283.7 L628.0 283.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M507.2 297.5 L631.2 297.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M510.4 311.2 L634.4 311.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M513.6 325.0 L637.6 325.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M472.4 160.7 L490.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M488.4 160.7 L506.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M504.4 160.7 L522.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M520.4 160.7 L538.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M536.4 160.7 L554.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M552.4 160.7 L570.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M568.4 160.7 L586.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M584.4 160.7 L602.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M600.4 160.7 L618.6 239.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M472.4 160.7 L616.4 160.7" stroke="#CFCBC2" stroke-width="0.6"/><path d="M475.6 174.5 L619.6 174.5" stroke="#CFCBC2" stroke-width="0.6"/><path d="M478.8 188.2 L622.8 188.2" stroke="#CFCBC2" stroke-width="0.6"/><path d="M482.0 202.0 L626.0 202.0" stroke="#CFCBC2" stroke-width="0.6"/><path d="M485.2 215.8 L629.2 215.8" stroke="#CFCBC2" stroke-wLine truncated
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,174 @@
|
||||
"""Isometric-like cutaway of the holiday flat (oblique projection), generated from plan coordinates (800 x 548 scan).
|
||||
|
||||
Output: SVG with floors, low walls and simple furniture; also prints the projected room polygons for click areas.
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
SHEAR, SQUASH = 0.2, 0.86 # oblique projection: X = x + SHEAR * y, Y = SQUASH * y - z
|
||||
OX, OY = 40, 30 # margin
|
||||
|
||||
NAVY, PAPER, LINE = '#13294B', '#FBFAF7', '#13294B'
|
||||
|
||||
|
||||
def project(x, y, z=0.0):
|
||||
return x + SHEAR * y, SQUASH * y - z
|
||||
|
||||
|
||||
shapes = [] # (depth, svg)
|
||||
|
||||
|
||||
def poly(points, fill, stroke=LINE, width=1.2, extra=''):
|
||||
pts = ' '.join(f'{round(px + OX, 1)},{round(py + OY, 1)}' for px, py in points)
|
||||
return f'<polygon points="{pts}" fill="{fill}" stroke="{stroke}" stroke-width="{width}" stroke-linejoin="round"{extra}/>'
|
||||
|
||||
|
||||
def signed_area(points):
|
||||
return sum(points[i][0] * points[(i + 1) % len(points)][1] - points[(i + 1) % len(points)][0] * points[i][1] for i in range(len(points))) / 2
|
||||
|
||||
|
||||
def prism(base, height, top, side, front=None, depth=None, z0=0.0, outline=LINE):
|
||||
"""Convex prism over a plan polygon; side faces drawn back-to-front with back-face culling."""
|
||||
front = front or side
|
||||
faces = []
|
||||
n = len(base)
|
||||
for i in range(n):
|
||||
(x1, y1), (x2, y2) = base[i], base[(i + 1) % n]
|
||||
quad = [project(x1, y1, z0), project(x2, y2, z0), project(x2, y2, z0 + height), project(x1, y1, z0 + height)]
|
||||
if signed_area(quad) <= 0:
|
||||
continue
|
||||
colour = front if abs(y1 - y2) < 1e-6 else side
|
||||
faces.append((max(y1, y2), poly(quad, colour, outline, 1.1)))
|
||||
faces.sort(key=lambda f: f[0])
|
||||
svg = ''.join(f for _, f in faces) + poly([project(x, y, z0 + height) for x, y in base], top, outline, 1.1)
|
||||
shapes.append((depth if depth is not None else max(y for _, y in base) + 0.001 * min(x for x, _ in base), svg))
|
||||
|
||||
|
||||
def box(x, y, w, d, h, top, side, front=None, z0=0.0, depth=None):
|
||||
prism([(x, y), (x + w, y), (x + w, y + d), (x, y + d)], h, top, side, front, depth, z0)
|
||||
|
||||
|
||||
def wall(x1, y1, x2, y2, t=6, h=22):
|
||||
dx, dy = x2 - x1, y2 - y1
|
||||
length = (dx * dx + dy * dy) ** 0.5
|
||||
nx, ny = -dy / length * t / 2, dx / length * t / 2
|
||||
base = [(x1 + nx, y1 + ny), (x2 + nx, y2 + ny), (x2 - nx, y2 - ny), (x1 - nx, y1 - ny)]
|
||||
if signed_area(base) < 0:
|
||||
base.reverse()
|
||||
prism(base, h, NAVY, '#FFFFFF', '#F1EFEA')
|
||||
|
||||
|
||||
# Rooms (same polygons as the click areas in the scan).
|
||||
ROOMS = {
|
||||
'terrasse': [(8, 150), (60, 150), (60, 300), (8, 300)],
|
||||
'wohnen': [(65, 150), (400, 150), (400, 245), (240, 245), (240, 350), (130, 350), (65, 290)],
|
||||
'kueche': [(240, 245), (400, 245), (400, 350), (240, 350)],
|
||||
'diele': [(400, 150), (548, 150), (548, 245), (400, 245)],
|
||||
'bad': [(403, 245), (531, 245), (531, 350), (403, 350)],
|
||||
'schlafen': [(548, 195), (720, 195), (720, 350), (535, 350), (535, 265)],
|
||||
}
|
||||
FLOORS = {'terrasse': '#C9976A', 'wohnen': '#E7D2AD', 'kueche': '#E9E7E1', 'diele': '#E9E7E1', 'bad': '#DCEFF5', 'schlafen': '#EAD9BC'}
|
||||
|
||||
floor_svg = []
|
||||
# lawn around the terrace and along the front
|
||||
floor_svg.append(poly([project(-40, 120), project(64, 120), project(64, 372), project(-40, 372)], '#CFE3C1', '#CFE3C1', 0))
|
||||
for key, points in ROOMS.items():
|
||||
floor_svg.append(poly([project(x, y) for x, y in points], FLOORS[key], '#B8B2A6', 0.8))
|
||||
# deck planks and tile grids
|
||||
for x in range(14, 60, 9):
|
||||
floor_svg.append(f'<path d="M{project(x, 150)[0] + OX:.1f} {project(x, 150)[1] + OY:.1f} L{project(x, 300)[0] + OX:.1f} {project(x, 300)[1] + OY:.1f}" stroke="#A97B52" stroke-width="0.8"/>')
|
||||
for (x0, y0, x1, y1) in ((242, 247, 398, 348), (405, 247, 529, 348), (402, 152, 546, 243)):
|
||||
step = 16
|
||||
for x in range(x0, x1, step):
|
||||
floor_svg.append(f'<path d="M{project(x, y0)[0] + OX:.1f} {project(x, y0)[1] + OY:.1f} L{project(x, y1)[0] + OX:.1f} {project(x, y1)[1] + OY:.1f}" stroke="#CFCBC2" stroke-width="0.6"/>')
|
||||
for y in range(y0, y1, step):
|
||||
floor_svg.append(f'<path d="M{project(x0, y)[0] + OX:.1f} {project(x0, y)[1] + OY:.1f} L{project(x1, y)[0] + OX:.1f} {project(x1, y)[1] + OY:.1f}" stroke="#CFCBC2" stroke-width="0.6"/>')
|
||||
|
||||
# Walls (outer and inner, with openings).
|
||||
for seg in [
|
||||
(65, 148, 238, 148), (238, 148, 548, 148), # north
|
||||
(548, 148, 548, 195), (548, 195, 720, 195), # entry corner, bedroom north
|
||||
(720, 195, 720, 352), # east
|
||||
]:
|
||||
wall(*seg)
|
||||
# Front walls are cut low (architectural model), so the rooms stay visible.
|
||||
for seg in [
|
||||
(720, 352, 610, 352), (560, 352, 130, 352), # south (gap = bedroom window)
|
||||
(130, 352, 65, 290), # diagonal
|
||||
(65, 290, 65, 262), (65, 182, 65, 148), # west (gap = terrace door)
|
||||
]:
|
||||
wall(*seg, h=7)
|
||||
for seg in [
|
||||
(400, 148, 400, 200), # living / hall partial
|
||||
(400, 245, 440, 245), (472, 245, 531, 245), # bath north with door
|
||||
(403, 245, 403, 352), (531, 245, 531, 352), # bath west/east
|
||||
(540, 195, 540, 252), (540, 292, 540, 352), # bedroom west with door
|
||||
]:
|
||||
wall(*seg)
|
||||
|
||||
# Furniture
|
||||
WOOD, WHITE, LEATHER, GLASS = '#B7895C', '#FFFFFF', '#2A4C7A', '#BFE4EE'
|
||||
box(238, 154, 116, 18, 28, '#F4F1EA', '#E6E1D6') # Schrankbett cabinet
|
||||
box(405, 154, 132, 18, 28, '#F4F1EA', '#E6E1D6') # hall wardrobe
|
||||
box(100, 160, 104, 34, 15, LEATHER, '#1F3B61') # sofa
|
||||
box(100, 160, 104, 10, 26, LEATHER, '#1F3B61', depth=162) # sofa back
|
||||
box(118, 208, 74, 34, 9, GLASS, '#9CCFDD') # glass table
|
||||
box(150, 258, 46, 40, 15, LEATHER, '#1F3B61') # relax chair
|
||||
box(84, 300, 52, 26, 20, WHITE, '#E9E6DF') # TV cabinet
|
||||
box(262, 252, 32, 92, 13, '#3A3A3A', '#2A2A2A') # dining table
|
||||
for cx, cy in ((246, 262), (246, 318), (298, 262), (298, 318)):
|
||||
box(cx, cy, 14, 14, 9, '#5B5B5B', '#444444') # chairs
|
||||
box(368, 250, 32, 100, 17, '#F7F6F2', '#E4E1D9') # kitchen counter (east)
|
||||
box(300, 322, 68, 28, 17, '#F7F6F2', '#E4E1D9') # kitchen counter (south)
|
||||
box(410, 262, 30, 34, 12, WHITE, '#E7EEF1') # toilet
|
||||
box(410, 310, 30, 30, 18, WHITE, '#E7EEF1') # wash basin
|
||||
box(478, 300, 48, 48, 30, '#E3F4F8', '#C6E6EE') # shower glass
|
||||
box(605, 238, 110, 106, 11, '#FFFFFF', '#E9E4DA') # bed
|
||||
box(605, 238, 110, 8, 24, WOOD, '#9C7149', depth=239) # headboard
|
||||
for px in (612, 662):
|
||||
box(px, 250, 44, 18, 15, '#F4F4F4', '#E2E2E2') # pillows
|
||||
box(580, 238, 22, 22, 15, WOOD, '#9C7149') # nightstands
|
||||
box(580, 320, 22, 22, 15, WOOD, '#9C7149')
|
||||
box(18, 196, 30, 30, 11, '#3A3A3A', '#2A2A2A') # terrace table
|
||||
for cx, cy in ((8, 204), (50, 204)):
|
||||
box(cx, cy, 10, 12, 14, '#4A4A4A', '#333333') # terrace chairs
|
||||
|
||||
# hob and sink on the kitchen counter
|
||||
extras = []
|
||||
for hx, hy in ((378, 268), (390, 268), (378, 282), (390, 282)):
|
||||
X, Y = project(hx, hy, 17)
|
||||
extras.append(f'<ellipse cx="{X + OX:.1f}" cy="{Y + OY:.1f}" rx="4.2" ry="3.4" fill="#2A2A2A"/>')
|
||||
X, Y = project(384, 318, 17)
|
||||
extras.append(f'<rect x="{X + OX - 9:.1f}" y="{Y + OY - 7:.1f}" width="18" height="12" rx="2" fill="#C9D3D8" stroke="#8A979E" stroke-width="0.8"/>')
|
||||
shapes.append((351, ''.join(extras)))
|
||||
# room names on the floors
|
||||
LABELS = {'wohnen': (180, 330, 'Wohnbereich'), 'kueche': (334, 300, 'Küche'), 'diele': (470, 232, 'Diele'), 'bad': (468, 264, 'Bad'), 'schlafen': (660, 300, 'Schlafzimmer'), 'terrasse': (34, 292, 'Terrasse')}
|
||||
labels = []
|
||||
for key, (lx, ly, text) in LABELS.items():
|
||||
X, Y = project(lx, ly)
|
||||
labels.append(f'<text x="{X + OX:.1f}" y="{Y + OY:.1f}" font-family="Newsreader, Georgia, serif" font-size="15" fill="#13294B" text-anchor="middle">{text}</text>')
|
||||
|
||||
shapes.sort(key=lambda s: s[0])
|
||||
# rhododendron bushes on the lawn
|
||||
bush = []
|
||||
for cx, cy, r in ((-14, 172, 20), (-18, 236, 18), (-10, 300, 22)):
|
||||
X, Y = project(cx, cy, 10)
|
||||
bush.append(f'<ellipse cx="{X + OX:.1f}" cy="{Y + OY:.1f}" rx="{r}" ry="{r * 0.75:.1f}" fill="#4E7A52"/>')
|
||||
for i, (dx, dy) in enumerate(((-8, -5), (4, -8), (9, 2), (-3, 4), (-10, 5), (6, 8))):
|
||||
bush.append(f'<circle cx="{X + OX + dx * r / 20:.1f}" cy="{Y + OY + dy * r / 20:.1f}" r="{3.2 if i % 2 else 4:.1f}" fill="#D9578B"/>')
|
||||
|
||||
xs, ys = [], []
|
||||
for x in (-40, 730):
|
||||
for y in (100, 395):
|
||||
for z in (0, 60):
|
||||
px, py = project(x, y, z)
|
||||
xs.append(px + OX); ys.append(py + OY)
|
||||
width, height = round(max(xs) + 20), round(max(ys) + 20)
|
||||
min_y = round(min(ys) - 10)
|
||||
|
||||
svg = (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 {min_y} {width} {height - min_y}" role="img" aria-label="Grundriss der Ferienwohnung in leichter 3D-Ansicht">'
|
||||
'<title>Grundriss der Ferienwohnung</title>' + ''.join(floor_svg) + ''.join(s for _, s in shapes) + ''.join(bush) + ''.join(labels) + '</svg>')
|
||||
open(sys.argv[1], 'w', encoding='utf-8').write(svg)
|
||||
|
||||
areas = {key: ' '.join(f'{round(project(x, y)[0] + OX, 1)},{round(project(x, y)[1] + OY, 1)}' for x, y in pts) for key, pts in ROOMS.items()}
|
||||
print(json.dumps({'viewBox': f'0 {min_y} {width} {height - min_y}', 'areas': areas}, indent=1))
|
||||
Reference in new issue
Block a user