mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
A space carried an aspect ratio, and coordinates were normalised against it: x by the width, y by the height. Every geometric question therefore depended on a per-space number, and picking a canvas orientation was a decision the user had no reason to make. The render space is now NORM_W x NORM_W and a plan image is fitted into it by its OWN ratio, centred — wide plans get margins above and below, tall ones at the sides. Migration (geometry_migration.py, pure and unit-tested) runs once at setup under the write lock. Nothing about a drawing changes: the old box is padded out to a square and every coordinate re-expressed against it — rooms as rects and polygons, openings and their lengths, decor, view_box, and the marker positions in the separate layout store. In render units it is a uniform scale plus an offset, so angles and proportions are exact. cell_cm is scaled for tall plans, because the grid pitch is a fraction of the width: without it a wall would measure less than it does. is now dropped by the schema rather than accepted — a stale tab sending it would be sending coordinates from the old normalisation too, and honouring the field would not make them right. The demo fixture was migrated with the same transform, so the smokes exercise the new geometry rather than a square-native fake; six of them needed their render-space helpers updated and one its click coordinates. Not released — dev only, per the owner's instruction.
22 lines
1.4 KiB
JavaScript
22 lines
1.4 KiB
JavaScript
// Split now works on a non-grid-aligned room (imported/legacy polygons).
|
|
import { launch, checkAll, finish } from './serve.mjs';
|
|
const { page, browser } = await launch();
|
|
const R = (nx, ny) => page.evaluate(([nx, ny]) => {
|
|
return [nx * 1000, ny * 1000]; // square canvas (v1.48.0)
|
|
}, [nx, ny]);
|
|
const out = {};
|
|
await page.evaluate(()=>{const c=window.__card; if(!c._markup)c._setMode('plan'); c._tool='split';});
|
|
// living room (r1) has walls at y=0.14 which are NOT grid nodes; click near the wall
|
|
await page.evaluate((p)=>window.__card._splitClick(p), await R(0.3,0.3)); // pick living
|
|
await page.evaluate((p)=>window.__card._splitClick(p), await R(0.3,0.142)); // near top wall (off grid)
|
|
await page.evaluate((p)=>window.__card._splitClick(p), await R(0.3,0.58)); // near bottom wall
|
|
out.pending = await page.evaluate(()=>!!window.__card._pendingSplit);
|
|
out.dialog = await page.evaluate(()=>!!window.__card._roomDialog);
|
|
// accidental click in the middle of the room must NOT become a wall point
|
|
await page.evaluate(()=>{const c=window.__card; c._roomDialog=false; c._pendingSplit=null; c._splitSel=null;});
|
|
await page.evaluate((p)=>window.__card._splitClick(p), await R(0.3,0.3)); // pick again
|
|
await page.evaluate((p)=>window.__card._splitClick(p), await R(0.3,0.3)); // centre click = miss
|
|
out.centreRefused = await page.evaluate(()=>window.__card._splitSel?.a == null);
|
|
checkAll(out);
|
|
await finish(browser, out);
|