显示调整

This commit is contained in:
tianmo committed 2026-09-19 11:15:44 +08:00
1 parent 081d06c70e
commit e2df519d2e
25 files changed
+291 -73

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
'use strict';
const assert = require('node:assert/strict');
const { findAlphaBounds, toWorldBounds } = require('../js/spine-visible-bounds');
const pixels = new Uint8Array(10 * 8 * 4);
for (let y = 2; y < 6; y++) {
for (let x = 3; x < 8; x++) pixels[(y * 10 + x) * 4 + 3] = 255;
}
assert.deepEqual(findAlphaBounds(pixels, 10, 8), { left: 3, top: 2, right: 8, bottom: 6 });
assert.deepEqual(toWorldBounds({ left: 3, top: 2, right: 8, bottom: 6 }, 10, 8, 2, 20, 30), {
x: 19,
y: 29,
width: 2.5,
height: 2,
});
assert.equal(findAlphaBounds(new Uint8Array(10 * 8 * 4), 10, 8), null);
console.log('PASS: visible alpha pixels map back to the correct Spine world bounds');