优化缩略图
This commit is contained in:
1 parent
081520dbd9
commit
fe4997f913
21 files changed
+128
-21
No files matched your search
@@ -63,7 +63,11 @@ for (const [name, plan] of Object.entries(priorities)) {
|
||||
const list = profilesModule.animatedProfiles(name);
|
||||
assert.equal(list.length, plan.length, name + ' 档位数必须跟随配置长度');
|
||||
list.forEach((profile, index) => {
|
||||
assert.equal(profile.size, plan[index][0], name + ' 第 ' + (index + 1) + ' 档分辨率');
|
||||
assert.equal(
|
||||
profile.size,
|
||||
Math.min(plan[index][0], profilesModule.DEFAULT_OUTPUT_SIZE),
|
||||
name + ' 第 ' + (index + 1) + ' 档分辨率(超过输出尺寸的要被压下来)',
|
||||
);
|
||||
assert.equal(profile.fps, plan[index][1], name + ' 第 ' + (index + 1) + ' 档帧率');
|
||||
assert.equal(profile.quality, plan[index][2], name + ' 第 ' + (index + 1) + ' 档质量');
|
||||
});
|
||||
@@ -74,6 +78,23 @@ assert.deepEqual(
|
||||
profilesModule.animatedProfiles(profilesModule.DEFAULT_PRIORITY),
|
||||
);
|
||||
|
||||
// 动态缩略图可选 200×200 或 400×400,默认 200(Eagle 缩略图格子里看不出差别,体积只有四分之一);
|
||||
// 配置里超过所选尺寸的细节分辨率会被自动压下来,所以同一份档位表两种尺寸都能用。
|
||||
assert.deepEqual(profilesModule.ANIMATED_OUTPUT_SIZES, [200, 400]);
|
||||
assert.equal(profilesModule.DEFAULT_OUTPUT_SIZE, 200);
|
||||
profilesModule.ANIMATED_PRIORITIES.__size = [[400, 15, 0.8], [100, 6, 0.2]];
|
||||
assert.deepEqual(profilesModule.animatedProfiles('__size').map((item) => item.size), [200, 100], '默认按 200 裁剪');
|
||||
assert.deepEqual(profilesModule.animatedProfiles('__size', 400).map((item) => item.size), [400, 100], '选 400 时保留 400');
|
||||
assert.ok(
|
||||
profilesModule.expandAnimatedPath('__size').every((item) => item.size <= profilesModule.DEFAULT_OUTPUT_SIZE),
|
||||
'插值路径不能超过默认输出尺寸',
|
||||
);
|
||||
assert.ok(
|
||||
profilesModule.expandAnimatedPath('__size', 400).every((item) => item.size <= 400),
|
||||
'选 400 时插值路径上限跟着放宽',
|
||||
);
|
||||
delete profilesModule.ANIMATED_PRIORITIES.__size;
|
||||
|
||||
// 插值路径供按目标体积定位使用:比锚点更密,首尾与锚点一致。
|
||||
// 配置允许分段(分辨率优先就是「400 系列 + 200 系列」),所以不要求整条路径单调。
|
||||
for (const name of Object.keys(priorities)) {
|
||||
@@ -98,14 +119,18 @@ for (const root of ['.', 'release/UNIVERSAL_SpineViewer']) {
|
||||
assert.match(script, /groupThumbBtn'[\s\S]*addEventListener\('contextmenu'[\s\S]*generateGroupThumbnails\(true\)/);
|
||||
assert.match(script, /async function generateGroupThumbnails\(animated = false\)/);
|
||||
assert.match(script, /if \(animated[\s\S]*renderAnimatedSourceFrames\(animation, options\)[\s\S]*pickAnimatedThumbnail\(source\.sourceFrames, source\.size, source\.range, options\)[\s\S]*renderCurrentFrameThumbnail\(\)/);
|
||||
assert.match(script, /const size = 400;/, 'animated output must remain fixed at 400x400');
|
||||
assert.match(script, /const size = options\.canvasSize \|\| animatedProfileConfig\.DEFAULT_OUTPUT_SIZE;/, '动态缩略图用界面选的输出尺寸');
|
||||
assert.match(script, /const size = 400;/, '静态缩略图仍然是 400×400');
|
||||
assert.match(html, /id="animatedThumbCanvas"/);
|
||||
assert.match(html, /<option value="200" selected>200 × 200<\/option>/);
|
||||
assert.match(script, /canvasSize: Number\(canvasInput\.value\) \|\| animatedProfileConfig\.DEFAULT_OUTPUT_SIZE/);
|
||||
assert.match(script, /async function renderAnimatedSourceFrames\(animation, options\)/);
|
||||
assert.match(script, /async function pickAnimatedThumbnail\(sourceFrames, size, range, options\)/);
|
||||
assert.match(script, /const targetBytes = options\.maxKilobytes \* 1024/);
|
||||
// 档位表来自独立配置文件,三种优先级都走画廊手动挑,不会自动应用。
|
||||
assert.match(script, /require\('\.\.\/js\/animated-profiles\.js'\)/);
|
||||
// 候选先估算整条路径的体积,再按「目标 0.5× ~ 2× 对数间隔」挑,覆盖面比挤在目标附近更宽。
|
||||
assert.match(script, /animatedProfileConfig\.expandAnimatedPath\(options\.priority\)/);
|
||||
assert.match(script, /animatedProfileConfig\.expandAnimatedPath\(options\.priority, options\.canvasSize\)/);
|
||||
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\)/);
|
||||
|
||||
Reference in new issue
Block a user