Two-axis Print Scale Lab | Sewlore
by sewinglore
HTML
<main>
<p class="eyebrow">SEWLORE · PRINT SCALE LAB</p>
<h1>One percentage cannot fix two unequal axes</h1>
<p>Measure a printed test square in both directions. Try one uniform scale adjustment and see what happens to each axis.</p>
<section class="panel" aria-labelledby="readings-title"><h2 id="readings-title">Enter hypothetical readings</h2>
<div class="controls"><label>Nominal side (mm)<input id="nominal" type="number" min="1" max="1000" step="any" value="100"></label><label>Printed width (mm)<input id="width" type="number" min="1" max="1000" step="any" value="100"></label><label>Printed height (mm)<input id="height" type="number" min="1" max="1000" step="any" value="96"></label><label>Uniform print scale (%)<input id="scale" type="number" min="1" max="1000" step="any" value="100"></label></div>
<p class="muted">Accepted range: 1–1,000 for each input. A numerical demo is not a printer setting recommendation.</p>
<div class="examples"><button id="unequal" type="button">100 × 96 example</button><button id="equal" type="button">49 × 49 example</button><button id="fitWidth" type="button">Fit width mathematically</button><button id="fitHeight" type="button">Fit height mathematically</button></div>
</section>
<section class="panel" aria-labelledby="result-title"><h2 id="result-title">Compare the result</h2><div id="error" class="error" role="alert"></div><div id="results" aria-live="polite">
<p id="status" class="status"></p><svg id="plot" viewBox="0 0 680 300" role="img" aria-labelledby="plotTitle plotDesc"><title id="plotTitle">Nominal and adjusted rectangular outlines</title><desc id="plotDesc">The dashed outline is the nominal test square; the solid outline shows the dimensions after applying the entered uniform scale. Read exact measurements in the table.</desc><rect id="target" fill="none" stroke="#173f39" stroke-width="3" stroke-dasharray="8 6"/><rect id="adjusted" fill="#b76d2b" fill-opacity=".12" stroke="#a45c23" stroke-width="3"/><text x="24"...
CSS
*{box-sizing:border-box}body{margin:0;background:#f4f0e7;color:#183f39;font:17px/1.55 system-ui,sans-serif}main{max-width:900px;margin:auto;padding:28px}h1{font-size:clamp(25px,4vw,38px);line-height:1.15}h2{font-size:23px}.eyebrow{font-size:13px;letter-spacing:.12em;font-weight:700}.panel{background:#fff;border:1px solid #c5d3cc;border-radius:14px;padding:22px;margin:20px 0}.controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));gap:18px}label{display:block;font-weight:600}input{display:block;max-width:100%;width:100%;font:inherit;padding:9px;border:1px solid #64897d;border-radius:6px}button{font:inherit;cursor:pointer;color:#183f39;background:#e8efea;border:1px solid #739286;border-radius:6px;padding:8px 14px;margin:5px 4px 0 0}button:focus-visible,input:focus-visible,a:focus-visible{outline:3px solid #b7692f;outline-offset:3px}svg{display:block;width:100%;height:auto;background:#f7f8f4;border:1px solid #d3ddd4}table{width:100%;border-collapse:collapse;margin-top:18px;font-variant-numeric:tabular-nums}td,th{padding:10px;text-align:left;border-bottom:1px solid #d5ded7}th{background:#edf2ee}.scroll{overflow-x:auto}a{color:#1e6453;text-decoration-thickness:2px}.muted{color:#526c63;font-size:14px}.error{color:#922c20;font-weight:600}.status{font-weight:700;font-size:19px}.examples{display:flex;gap:5px;flex-wrap:wrap}@media(max-width:550px){main{padding:16px}.panel{padding:16px}td,th{padding:7px;font-size:14px}}
JavaScript
'use strict';
// Original Sewlore educational math. Examples are hypothetical.
function printScaleResult(nominal, width, height, scale) {
const values = [nominal, width, height, scale];
if (!values.every(v => typeof v === 'number' && Number.isFinite(v) && v >= 1 && v <= 1000)) throw new RangeError('Enter finite values from 1 to 1,000 in all four fields.');
const adjustedWidth = width * scale / 100;
const adjustedHeight = height * scale / 100;
return {nominal, width, height, scale, widthRatio: width / nominal, heightRatio: height / nominal,
adjustedWidth, adjustedHeight, widthChange: (adjustedWidth / nominal - 1) * 100,
heightChange: (adjustedHeight / nominal - 1) * 100,
widthScale: 100 * nominal / width, heightScale: 100 * nominal / height,
equalRatios: width === height,
bothMatch: width === height && Math.abs(adjustedWidth - nominal) <= 8 * Number.EPSILON * nominal && Math.abs(adjustedHeight - nominal) <= 8 * Number.EPSILON * nominal};
}
if (typeof module !== 'undefined' && module.exports) module.exports = {printScaleResult};
if (typeof document !== 'undefined') {
const ids = ['nominal', 'width', 'height', 'scale'];
const el = id => document.getElementById(id);
const fmt = v => Number(v.toFixed(4)).toLocaleString('en', {maximumFractionDigits: 4});
function redraw() {
try {
const r = printScaleResult(...ids.map(id => Number(el(id).value)));
el('error').textContent = ''; el('results').hidden = false;
el('status').textContent = r.bothMatch ? 'Both axes match in this numerical calculation. Re-print and measure to check physical output.' : r.equalRatios ? 'Equal ratios: one uniform multiplier can correct both axes mathematically.' : 'Unequal ratios: one uniform multiplier cannot correct both axes.';
el('axisRows').replaceChildren();
...