- 면적표 글자 = 그림 칸 폭 비례(clamp · cqw) · 표 높이 변수 같은 식 · 4열부터 「계」만(그리드 data-columns) - [상세] 그림 = 테마 토큰(어두운 고정색 지움) · 카드 그리기 함수로 모달 칸 크기에 맞춰 새로 그림(fitPlotBase · 빈 띠 없음) - 칸 크기 바뀌면 다시 그림(ResizeObserver) · clip id 카드와 가름 · 그리는 동안 refresh 되먹임 막음 - 시험 test_173_areas_detail 새로 · test_164 · test_150 단정 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JywHxQuWPk6UYXTebyrBoU
48 lines
2.2 KiB
JavaScript
48 lines
2.2 KiB
JavaScript
/* 173-4 [상세] 그림 칸 가득 — `B06_Section_UI_Cross_View_Metrics.ts` `fitPlotBase` 를 그 자리에서 트랜스파일해 Node 로 돌림.
|
|
* 결과 = 표준출력 JSON 한 벌. 짝 = `test_173_areas_detail.py`.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const B06 = path.join(__dirname, "..", "..", "B06_Section");
|
|
const common = fs.readFileSync(path.join(B06, "B06_Section_UI_Section_Common.ts"), "utf8");
|
|
// 카드 여백 · 바닥 높이는 원본에서 읽음(화면과 같은 값)
|
|
const CROSS_PAD = Function(`return ${/export const CROSS_PAD = (\{[^}]*\})/.exec(common)[1]}`)();
|
|
const CROSS_HEIGHT = Number(/export const CROSS_HEIGHT = (\d+)/.exec(common)[1]);
|
|
const stub = {
|
|
CROSS_PAD,
|
|
CROSS_HEIGHT,
|
|
validElevation: (s) => Number.isFinite(s.elevation_m),
|
|
};
|
|
const js = ts.transpileModule(
|
|
fs.readFileSync(path.join(B06, "B06_Section_UI_Cross_View_Metrics.ts"), "utf8"),
|
|
{ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 } },
|
|
).outputText;
|
|
const box = { exports: {} };
|
|
new Function("exports", "module", "require", js)(box.exports, box, () => stub);
|
|
const m = box.exports;
|
|
|
|
// 반폭 10 m · 높이 차 8 m — 넓은 칸(1200 × 400)에선 자연 높이가 칸보다 큼
|
|
const section = {
|
|
samples: [-10, -5, 0, 5, 10].map((offset_m, i) => ({ offset_m, elevation_m: 100 + i * 2 })),
|
|
};
|
|
const base = m.crossPlotBase(section, 1, 1200, 10, 104);
|
|
const fit = m.fitPlotBase(base, 400);
|
|
const plot = m.crossPlotFromBase(fit, 400);
|
|
const tall = m.fitPlotBase(base, base.naturalHeight + 100);
|
|
const out = {
|
|
natural: base.naturalHeight,
|
|
fitHeight: fit.naturalHeight,
|
|
plotHeight: plot.heightPx,
|
|
// 도면 폭(px) 그대로 = m당 px × 가로 범위
|
|
innerBefore: base.pixelsPerMeter * (base.maxOffset - base.minOffset),
|
|
innerAfter: fit.pixelsPerMeter * (fit.maxOffset - fit.minOffset),
|
|
// 좌우 같이 넓힘 — 가운데 그대로
|
|
midBefore: (base.maxOffset + base.minOffset) / 2,
|
|
midAfter: (fit.maxOffset + fit.minOffset) / 2,
|
|
wider: fit.maxOffset - fit.minOffset > base.maxOffset - base.minOffset,
|
|
tallSame: tall === base,
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|