优化缩略图

This commit is contained in:
Yeomai committed 2026-09-20 01:14:46 +08:00
1 parent e94dfb9e35
commit 081520dbd9
5 files changed
+259 -15

No files matched your search

+23 -1
View File
@@ -74,6 +74,21 @@ assert.deepEqual(
profilesModule.animatedProfiles(profilesModule.DEFAULT_PRIORITY),
);
// 插值路径供按目标体积定位使用:比锚点更密,首尾与锚点一致。
// 配置允许分段(分辨率优先就是「400 系列 + 200 系列」),所以不要求整条路径单调。
for (const name of Object.keys(priorities)) {
const anchors = profilesModule.animatedProfiles(name);
const path = profilesModule.expandAnimatedPath(name);
assert.ok(path.length > anchors.length, name + ' 插值后应比锚点更密');
assert.deepEqual(path[0], anchors[0], name + ' 路径首点必须等于首个锚点');
assert.deepEqual(path[path.length - 1], anchors[anchors.length - 1], name + ' 路径末点必须等于末尾锚点');
for (const profile of path) {
assert.ok(profile.size >= 1 && profile.size <= 400, name + ' 插值分辨率必须落在 1-400');
assert.ok(profile.fps >= 1, name + ' 插值帧率至少为 1');
assert.ok(profile.quality > 0 && profile.quality <= 1, name + ' 插值质量必须落在 (0,1]');
}
}
for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
const html = fs.readFileSync(root + '/viewer/spine.html', 'utf8');
const css = fs.readFileSync(root + '/viewer/spine.css', 'utf8');
@@ -89,7 +104,14 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
assert.match(script, /const targetBytes = options\.maxKilobytes \* 1024/);
// 档位表来自独立配置文件,三种优先级都走画廊手动挑,不会自动应用。
assert.match(script, /require\('\.\.\/js\/animated-profiles\.js'\)/);
assert.match(script, /const profiles = animatedProfiles\(options\.priority\)/);
// 候选先估算整条路径的体积,再按「目标 0.5× ~ 2× 对数间隔」挑,覆盖面比挤在目标附近更宽。
assert.match(script, /animatedProfileConfig\.expandAnimatedPath\(options\.priority\)/);
assert.match(script, /pickAnimatedCandidates\(\s*searchPath, sourceFrames, size, range, options, targetBytes, candidateCount, encodeFrame,?\s*\)/);
assert.match(script, /const low = Math\.log\(Math\.max\(samples\[0\]\.bytes, targetBytes \* 0\.5\)\)/);
assert.match(script, /const wanted = Math\.exp\(low \+ \(high - low\) \* slot \/ span\)/);
assert.match(script, /samples\.sort\(\(left, right\) => left\.bytes - right\.bytes\)/);
// 估算用动画 1/3 和 2/3 处的帧,避开首尾信息不全的画面。
assert.match(script, /const indexes = \[Math\.round\(count \/ 3\), Math\.round\(count \* 2 \/ 3\)\]/);
assert.match(html, /id="animatedThumbPriority"/);
assert.match(script, /priorityInput\.value = animatedProfileConfig\.DEFAULT_PRIORITY/);
assert.match(script, /priority: priorityInput\.value/);