One cabinet in plan
64-bitThe cabinet seen from above in its own frame, with its fronts, number and width label.
W = w × k; D = d × k; label = round(w × 100) ÷ 100
Sizes are multiplied by k, drawing units per rule unit. The width label is rounded to 2 decimals, so 23.0625 is written 23.06. Text sizes use k ÷ 25.4 for inch rules.
export function planEnts(cab, R, k = 1) {
const W = cab.w * k, D = cab.d * k, F = R.frontT * k;
const out = [rect(0, 0, W, D)];
// fronts across the cabinet's face (doors or drawers: the same strip seen from above), with the reveals
for (const f of frontsOf(cab, R).filter((g, i, a) => a.findIndex((h) => h.x === g.x) === i)) out.push(rect(f.x * k, D, f.w * k, F));
if (cab.type === 'wall') out.push(ln(0, 0, W, D), ln(0, D, W, 0));
if (cab.type === 'tall') out.push(ln(0, 0, W, D));
// a wall cabinet hangs over a base one in plan: its words sit near the wall, a base cabinet's near the front, so they don't meet
const mmK = k * (R.unit === 'in' ? 1 / 25.4 : 1); // drawing units per mm
const h = Math.min(D * 0.16, W * 0.12, 60 * mmK), wallish = cab.type === 'wall';
const ty = wallish ? D * 0.5 : Math.max(D * 0.62, Math.min(D - h * 0.8, 400 * mmK));
out.push({ type: 'text', x: W / 2, y: ty, h, rot: 0, s: cab.no, ha: 'center', va: 'middle' });
out.push({ type: 'text', x: W / 2, y: ty - h * 1.5, h: h * 0.7, rot: 0, s: fmt(cab.w), ha: 'center', va: 'middle' });
return out;
}