Test transparent health and top HUD assets
This commit is contained in:
parent
9ae626d5f8
commit
e740be97a0
@ -7,6 +7,8 @@ import rightControls from '../src/assets/controller/right-controls.js';
|
||||
import cannonRoundel from '../src/assets/controller/cannon-roundel.js';
|
||||
import helmFrame from '../src/assets/controller/helm-frame.js';
|
||||
import helmKnob from '../src/assets/controller/helm-knob.js';
|
||||
import playerHealth from '../src/assets/controller/player-health.js';
|
||||
import enemyHealth from '../src/assets/controller/enemy-health.js';
|
||||
|
||||
const assets = {
|
||||
topHud,
|
||||
@ -15,6 +17,8 @@ const assets = {
|
||||
cannonRoundel,
|
||||
helmFrame,
|
||||
helmKnob,
|
||||
playerHealth,
|
||||
enemyHealth,
|
||||
};
|
||||
|
||||
const decodeWebP = (name, dataUrl) => {
|
||||
@ -40,3 +44,20 @@ for (const [name, dataUrl] of Object.entries(assets)) {
|
||||
decodeWebP(name, dataUrl);
|
||||
});
|
||||
}
|
||||
|
||||
const alphaAssets = {
|
||||
topHud,
|
||||
playerHealth,
|
||||
enemyHealth,
|
||||
};
|
||||
|
||||
for (const [name, dataUrl] of Object.entries(alphaAssets)) {
|
||||
test(`${name} carries WebP transparency data`, () => {
|
||||
const match = /^data:image\/webp;base64,([A-Za-z0-9+/=]+)$/.exec(dataUrl);
|
||||
assert.ok(match, `${name} must be a WebP data URL`);
|
||||
const bytes = Buffer.from(match[1], 'base64');
|
||||
const hasAlphaChunk = bytes.includes(Buffer.from('ALPH'));
|
||||
const usesLosslessWebP = bytes.includes(Buffer.from('VP8L'));
|
||||
assert.ok(hasAlphaChunk || usesLosslessWebP, `${name} should preserve transparent background data`);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user