显示调整

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

+14 -1
View File
@@ -58,6 +58,10 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
assert.match(script, /return smallest;/);
assert.doesNotMatch(script, /throw new Error\(t\('viewer\.animatedCannotFit'/);
assert.match(script, /require\('\.\.\/js\/animated-webp-encoder\.js'\)/);
assert.match(script, /require\('\.\.\/js\/spine-visible-bounds\.js'\)/);
assert.match(script, /async function measureVisibleBounds/);
assert.match(script, /const bounds = await measureVisibleBounds\(skeleton, geometryBounds, 1/);
assert.match(script, /measureVisibleBounds\(previewSkeleton, bounds, sampleTimes\.length/);
assert.match(script, /async function encodeAnimatedWebpToLimit/);
assert.match(script, /canvas\.toDataURL\('image\/webp', profile\.quality\)/);
assert.match(script, /extension: options\.format === 'apng' \? '\.png' : '\.webp'/);
@@ -67,10 +71,19 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
assert.match(html, /id="animatedThumbStart" type="number" min="0" step="1"/);
assert.match(html, /id="animatedThumbEnd" type="number" min="0" step="1"/);
assert.match(html, /data-i18n="viewer\.framesUnit"/);
assert.match(html, /id="animatedThumbMaxSize" type="number" min="50" max="10240" step="50" value="100"/);
assert.match(html, /id="animatedThumbMaxSize" type="number" min="10" max="1024" step="10" value="30"/);
assert.match(html, /class="animated-thumb-danger" data-i18n="viewer\.animatedThumbnailDanger"/);
assert.match(html, /class="animated-thumb-warning-title" data-i18n="viewer\.animatedThumbnailAttention"/);
assert.match(css, /\.animated-thumb-warning-title \{ display: block; \}/);
assert.match(script, /maxSizeInput\.value = '30'/);
assert.match(script, /maxKilobytes < 10 \|\| maxKilobytes > 1024/);
assert.doesNotMatch(script, /startInput\.(?:focus|select)\(\)/);
assert.match(script, /document\.activeElement\.blur\(\)/);
assert.doesNotMatch(html, /id="animatedThumbQuality"/);
assert.doesNotMatch(html, /viewer\.secondsUnit/);
assert.match(html, /id="animatedThumbDialog"/);
assert.match(html, /id="animatedThumbDialogTitle"[^>]*>生成动态缩略图<\/div>/);
assert.match(css, /\.animated-thumb-card \.thumb-dialog-title \{ text-align: center; \}/);
assert.match(html, /id="animatedThumbFormat"><option value="webp">AWebP \(\.webp\)<\/option><option value="apng">APNG \(\.png\)<\/option>/);
assert.match(css, /\.animated-thumb-form \{[^}]*grid-template-columns: 96px minmax\(0, 1fr\)/);
assert.match(css, /\.animated-thumb-form input\[type="number"\]/);
+2
View File
@@ -17,6 +17,7 @@ function functionBody(source, name, nextName) {
for (const root of roots) {
const viewerPath = path.join(root, 'viewer/spine.html');
const html = fs.readFileSync(viewerPath, 'utf8');
const css = fs.readFileSync(path.join(root, 'viewer/spine.css'), 'utf8');
const script = html.match(/<script>([\s\S]*?)<\/script>/)[1];
new vm.Script(script);
@@ -33,6 +34,7 @@ for (const root of roots) {
const capture = functionBody(script, 'captureStableFitBounds', 'fitToCanvas');
assert.match(capture, /getBounds\(skeleton\)/);
assert.match(css, /#status \{\s*position: absolute; left: 50%;[^}]*transform: translateX\(-50%\)/, 'status notice must be horizontally centered');
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'manifest.json'), 'utf8'));
for (const language of manifest.languages) {
+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');