feat(capture): shared crop_fill + tape geometry for #99
- One crop_fill (default 0.9) replaces duplicated FILL in inventory/overlay - Thin localStorage settings store; crop % only moves long-axis end insets - Pure tapeGeometry: fixed stage line, stage↔image map, tick span → px - measure() prefers tape tick span for scale; maskSpanAlong demoted - rotateCalibration bakes cal tilt into inventory + overlay only - Fix stale 80%-fill comment on slabBounds
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Thin frontend-only crop_fill setting (#99).
|
||||
* Default 0.9 — replaces duplicated FILL = 0.9 in png/inventory + png/overlay.
|
||||
* Not a full M3 Settings surface; localStorage so it survives reloads.
|
||||
*/
|
||||
import { DEFAULT_CROP_FILL, clampFill } from '../png/crop';
|
||||
|
||||
const KEY = 'slabuploader.crop_fill';
|
||||
|
||||
let cached: number | null = null;
|
||||
|
||||
export function getCropFill(): number {
|
||||
if (cached != null) return cached;
|
||||
if (typeof localStorage === 'undefined') {
|
||||
cached = DEFAULT_CROP_FILL;
|
||||
return cached;
|
||||
}
|
||||
try {
|
||||
const raw = localStorage.getItem(KEY);
|
||||
if (raw == null) {
|
||||
cached = DEFAULT_CROP_FILL;
|
||||
return cached;
|
||||
}
|
||||
cached = clampFill(Number.parseFloat(raw));
|
||||
return cached;
|
||||
} catch {
|
||||
cached = DEFAULT_CROP_FILL;
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
|
||||
export function setCropFill(fill: number): number {
|
||||
const next = clampFill(fill);
|
||||
cached = next;
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
try {
|
||||
localStorage.setItem(KEY, String(next));
|
||||
} catch {
|
||||
/* private mode / quota — in-memory still updated */
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
/** Test helper: clear cached value (and optional storage). */
|
||||
export function _resetCropFillForTests(): void {
|
||||
cached = null;
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
try {
|
||||
localStorage.removeItem(KEY);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user