Files
2026-09-14 02:12:53 -07:00

18 lines
799 B
JavaScript

import { sampleWidthsPx } from './src/lib/core/measure.js';
const W = 200, H = 150;
const mask = new Uint8Array(W * H);
// slab 336 x 192 px at (0,0) — extends beyond photo bounds (200x150)
for (let y = 0; y < H; y++)
for (let x = 0; x < W; x++)
mask[y * W + x] = (x < 336 && y < 192) ? 1 : 0;
const axis = { origin: {x:0, y:0}, dir: {x:1, y:0}, lengthPx: 336 };
const w = sampleWidthsPx(mask, W, H, axis, 160, 6);
console.log('widths:', w);
// sample points at t=0, 96, 192, 288 px
// perpendicular dir: (0,1) — scan down
// at x=0: y from 0..149 all in slab (y<192) → width 150 (clamped by photo)
// at x=96: same → 150
// at x=192: same → 150
// at x=288: x=288 > 200 (photo width) → out of bounds → 0? or skipped?
console.log('expected: [150, 150, 150] or [150, 150, 150, 0]');