fix: promote approved Gaming character art
This commit is contained in:
13 files changed
+153
-13
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 143 KiB |
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"source": "alter-ego-gaming-half-body.png",
|
||||
"formats": [ "avif", "webp" ],
|
||||
"widths": [ 384, 768 ]
|
||||
}
|
||||
+1
-1
@@ -631,7 +631,7 @@ function chrnx_get_topic_art_asset( string $topic_slug ): string {
|
||||
'music-collage' => 'the-no-names-collage.jpeg',
|
||||
'podcasts' => 'alter-ego-podcasts.png',
|
||||
'life' => 'alter-ego-life.png',
|
||||
'gaming' => 'alter-ego-gaming.png',
|
||||
'gaming' => 'alter-ego-gaming-half-body.png',
|
||||
);
|
||||
return isset( $mapping[ $topic_slug ] ) ? 'assets/images/' . $mapping[ $topic_slug ] : '';
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ for chrnx_image_topic in code gaming life literature podcasts research; do
|
||||
printf '{\n\t"source": "alter-ego-%s.png",\n\t"formats": [ "avif", "webp" ],\n\t"widths": [ 384, 768 ]\n}\n' "$chrnx_image_topic" > "$chrnx_image_output/alter-ego-$chrnx_image_topic.json"
|
||||
done
|
||||
|
||||
chrnx_build_responsive_image "alter-ego-gaming-half-body" "alter-ego-gaming-half-body.png"
|
||||
printf '{\n\t"source": "alter-ego-gaming-half-body.png",\n\t"formats": [ "avif", "webp" ],\n\t"widths": [ 384, 768 ]\n}\n' > "$chrnx_image_output/alter-ego-gaming-half-body.json"
|
||||
|
||||
chrnx_build_responsive_image "the-no-names-musician-cutout" "the-no-names-musician-cutout.png"
|
||||
printf '{\n\t"source": "the-no-names-musician-cutout.png",\n\t"formats": [ "avif", "webp" ],\n\t"widths": [ 384, 768 ]\n}\n' > "$chrnx_image_output/the-no-names-musician-cutout.json"
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ ALTER_EGO_ASSETS = (
|
||||
"alter-ego-life.png",
|
||||
"alter-ego-gaming.png",
|
||||
)
|
||||
ALTER_EGO_SOURCE_ASSETS = (*ALTER_EGO_ASSETS, "alter-ego-gaming-half-body.png")
|
||||
CONTACT_SHEET_SCRIPT = PROJECT_ROOT / "scripts" / "build-alter-ego-contact-sheet.py"
|
||||
|
||||
|
||||
@@ -33,9 +34,9 @@ def test_opaque_coverage_counts_near_opaque_alpha() -> None:
|
||||
|
||||
|
||||
def test_alter_ego_asset_inventory_and_image_contract() -> None:
|
||||
expected = set(ALTER_EGO_ASSETS)
|
||||
expected = set(ALTER_EGO_SOURCE_ASSETS)
|
||||
actual = {path.name for path in ASSET_DIRECTORY.glob("alter-ego-*.png")}
|
||||
missing = [name for name in ALTER_EGO_ASSETS if name not in actual]
|
||||
missing = [name for name in ALTER_EGO_SOURCE_ASSETS if name not in actual]
|
||||
unexpected = sorted(actual - expected)
|
||||
inventory_violations = [
|
||||
*(f"missing assets/images/{name}" for name in missing),
|
||||
@@ -46,7 +47,7 @@ def test_alter_ego_asset_inventory_and_image_contract() -> None:
|
||||
)
|
||||
|
||||
violations: list[str] = []
|
||||
for name in ALTER_EGO_ASSETS:
|
||||
for name in ALTER_EGO_SOURCE_ASSETS:
|
||||
path = ASSET_DIRECTORY / name
|
||||
with Image.open(path) as image:
|
||||
if image.format != "PNG":
|
||||
@@ -92,6 +93,24 @@ def test_alter_ego_asset_inventory_and_image_contract() -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_gaming_half_body_preserves_original_and_has_prominent_visible_alpha() -> None:
|
||||
original = ASSET_DIRECTORY / "alter-ego-gaming.png"
|
||||
half_body = ASSET_DIRECTORY / "alter-ego-gaming-half-body.png"
|
||||
assert original.read_bytes() != half_body.read_bytes()
|
||||
|
||||
with Image.open(original) as original_image, Image.open(half_body) as half_body_image:
|
||||
assert original_image.size == half_body_image.size == (1024, 1536)
|
||||
original_box = original_image.getchannel("A").point(
|
||||
lambda value: 255 if value >= 16 else 0
|
||||
).getbbox()
|
||||
half_body_box = half_body_image.getchannel("A").point(
|
||||
lambda value: 255 if value >= 16 else 0
|
||||
).getbbox()
|
||||
assert original_box == (170, 54, 882, 1475)
|
||||
assert half_body_box == (15, 79, 948, 1536)
|
||||
assert (half_body_box[2] - half_body_box[0]) / 1024 >= 0.90
|
||||
|
||||
|
||||
def _install_contact_sheet_script(project_root: Path) -> Path:
|
||||
assert CONTACT_SHEET_SCRIPT.is_file(), (
|
||||
f"Missing contact-sheet script: {CONTACT_SHEET_SCRIPT}"
|
||||
|
||||
@@ -33,6 +33,36 @@ const characterSurfaces = [
|
||||
),
|
||||
];
|
||||
|
||||
const characterVisibleAlphaBounds = {
|
||||
'alter-ego-code': [ 1122, 1402, 87, 204, 1022, 1172 ],
|
||||
'alter-ego-gaming-half-body': [ 1024, 1536, 15, 79, 948, 1536 ],
|
||||
'alter-ego-life': [ 1122, 1402, 25, 81, 1078, 1402 ],
|
||||
'alter-ego-literature': [ 1122, 1402, 51, 48, 1072, 1359 ],
|
||||
'alter-ego-podcasts': [ 1122, 1402, 62, 110, 1101, 1338 ],
|
||||
'alter-ego-research': [ 1122, 1402, 106, 52, 1074, 1402 ],
|
||||
'the-no-names-musician-cutout': [ 1122, 1402, 0, 46, 1102, 1402 ],
|
||||
};
|
||||
|
||||
async function positionStageBelowStickyHeader( page, stage ) {
|
||||
await stage.scrollIntoViewIfNeeded();
|
||||
await page.evaluate(
|
||||
( element ) => {
|
||||
const header = document.querySelector( 'header.wp-block-template-part' );
|
||||
const overlap = header.getBoundingClientRect().bottom - element.getBoundingClientRect().top;
|
||||
if ( overlap > 0 ) {
|
||||
window.scrollBy( 0, -( overlap + 16 ) );
|
||||
}
|
||||
},
|
||||
await stage.elementHandle(),
|
||||
);
|
||||
await page.evaluate(
|
||||
() =>
|
||||
new Promise( ( resolve ) =>
|
||||
window.requestAnimationFrame( () => window.requestAnimationFrame( resolve ) ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function setExplicitTheme( page, theme ) {
|
||||
await page.addInitScript( ( value ) => {
|
||||
window.localStorage.setItem( 'chrnx-theme', value );
|
||||
@@ -816,7 +846,7 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
|
||||
priority: element.querySelector( ':scope > .chrnx-character-stage__art picture img' )
|
||||
?.fetchPriority,
|
||||
} ) );
|
||||
await stage.scrollIntoViewIfNeeded();
|
||||
await positionStageBelowStickyHeader( page, stage );
|
||||
await stage
|
||||
.locator( ':scope > .chrnx-character-stage__art picture img' )
|
||||
.evaluate( ( image ) => image.decode() );
|
||||
@@ -854,6 +884,48 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
|
||||
expect( geometry.pictureZ ).toBeGreaterThan( geometry.secondaryZ );
|
||||
expect( geometry.pictureZ ).toBeGreaterThan( geometry.collageZ );
|
||||
expect( geometry.effect ).not.toBe( 'none|none|none|none' );
|
||||
const painted = await stage.evaluate( ( element, boundsByAsset ) => {
|
||||
const image = element.querySelector( ':scope > .chrnx-character-stage__art picture img' );
|
||||
const sourceName = new URL( image.src ).pathname
|
||||
.split( '/' )
|
||||
.pop()
|
||||
.replace( /\.png$/, '' );
|
||||
const [ naturalWidth, naturalHeight, x0, y0, x1, y1 ] = boundsByAsset[ sourceName ];
|
||||
const imageRect = image.getBoundingClientRect();
|
||||
const stageRect = element.getBoundingClientRect();
|
||||
const scale = Math.min(
|
||||
imageRect.width / naturalWidth,
|
||||
imageRect.height / naturalHeight,
|
||||
);
|
||||
const objectWidth = naturalWidth * scale;
|
||||
const objectHeight = naturalHeight * scale;
|
||||
const objectLeft = imageRect.left + ( imageRect.width - objectWidth ) / 2;
|
||||
const objectTop = imageRect.bottom - objectHeight;
|
||||
const visible = {
|
||||
left: objectLeft + x0 * scale,
|
||||
top: objectTop + y0 * scale,
|
||||
right: objectLeft + x1 * scale,
|
||||
bottom: objectTop + y1 * scale,
|
||||
};
|
||||
return {
|
||||
sourceName,
|
||||
widthRatio: ( visible.right - visible.left ) / stageRect.width,
|
||||
heightRatio: ( visible.bottom - visible.top ) / stageRect.height,
|
||||
contained:
|
||||
visible.left >= stageRect.left - 1 &&
|
||||
visible.right <= stageRect.right + 1 &&
|
||||
visible.top >= stageRect.top - 1 &&
|
||||
visible.bottom <= stageRect.bottom + 1,
|
||||
};
|
||||
}, characterVisibleAlphaBounds );
|
||||
expect( painted.widthRatio, `${ surface.name } painted width` ).toBeGreaterThanOrEqual(
|
||||
mobile ? 0.45 : 0.36,
|
||||
);
|
||||
expect( painted.heightRatio ).toBeGreaterThanOrEqual( 0.28 );
|
||||
expect( painted.contained ).toBeTruthy();
|
||||
if ( surface.name === 'topic-gaming' ) {
|
||||
expect( painted.sourceName ).toBe( 'alter-ego-gaming-half-body' );
|
||||
}
|
||||
if ( surface.name === 'home-music' || surface.name === 'music' ) {
|
||||
expect( geometry.collageLoading ).toBe( 'lazy' );
|
||||
}
|
||||
@@ -893,10 +965,37 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
|
||||
expect( initial.loading ).not.toBe( 'eager' );
|
||||
expect( initial.priority ).not.toBe( 'high' );
|
||||
}
|
||||
await testInfo.attach(
|
||||
`character-stage-${ surface.name }-${ viewport.width }-${ theme }.png`,
|
||||
{ body: await stage.screenshot(), contentType: 'image/png' },
|
||||
);
|
||||
const captureContract = await stage.evaluate( ( element ) => {
|
||||
const header = document.querySelector( 'header.wp-block-template-part' );
|
||||
const heading = element.querySelector( 'h1, h2, h3, h4, h5, h6' );
|
||||
const headerRect = header.getBoundingClientRect();
|
||||
const stageRect = element.getBoundingClientRect();
|
||||
const headingRect = heading.getBoundingClientRect();
|
||||
return {
|
||||
headerIntersects:
|
||||
headerRect.bottom > stageRect.top && headerRect.top < stageRect.bottom,
|
||||
headingContained:
|
||||
headingRect.top >= stageRect.top && headingRect.bottom <= stageRect.bottom,
|
||||
};
|
||||
} );
|
||||
expect( captureContract.headerIntersects ).toBeFalsy();
|
||||
expect( captureContract.headingContained ).toBeTruthy();
|
||||
const header = page.locator( 'header.wp-block-template-part' );
|
||||
await header.evaluate( ( element ) => {
|
||||
element.dataset.characterCaptureVisibility = element.style.visibility;
|
||||
element.style.visibility = 'hidden';
|
||||
} );
|
||||
try {
|
||||
await testInfo.attach(
|
||||
`character-stage-${ surface.name }-${ viewport.width }-${ theme }.png`,
|
||||
{ body: await stage.screenshot(), contentType: 'image/png' },
|
||||
);
|
||||
} finally {
|
||||
await header.evaluate( ( element ) => {
|
||||
element.style.visibility = element.dataset.characterCaptureVisibility;
|
||||
delete element.dataset.characterCaptureVisibility;
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
'music' => 'the-no-names-musician-cutout.png',
|
||||
'podcasts' => 'alter-ego-podcasts.png',
|
||||
'life' => 'alter-ego-life.png',
|
||||
'gaming' => 'alter-ego-gaming.png',
|
||||
'gaming' => 'alter-ego-gaming-half-body.png',
|
||||
);
|
||||
foreach ( $expected as $slug => $filename ) {
|
||||
$this->assertSame( 'assets/images/' . $filename, chrnx_get_topic_art_asset( $slug ) );
|
||||
@@ -654,6 +654,7 @@ class BlockRenderingTest extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertStringContainsString( 'width="1024"', $gaming );
|
||||
$this->assertStringContainsString( 'height="1536"', $gaming );
|
||||
$this->assertStringContainsString( 'alter-ego-gaming-half-body', $gaming );
|
||||
}
|
||||
|
||||
/** Topic heroes share the three-layer stage and unknown topics retain a safe labeled fallback. */
|
||||
|
||||
@@ -231,7 +231,7 @@ class PatternsTest extends WP_UnitTestCase {
|
||||
'order' => array( 'About', 'I work as Lead Developer @Expressive Tea', 'I am a published researcher.', 'I am an autistic Level 1 software developer and researcher.', 'Beyond the work', 'I am the father of three wonderful children' ),
|
||||
'art' => 'alter-ego-life.png',
|
||||
'art_alt' => '',
|
||||
'facets' => array( 'alter-ego-literature.png', 'alter-ego-gaming.png' ),
|
||||
'facets' => array( 'alter-ego-literature.png', 'alter-ego-gaming-half-body.png' ),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -181,8 +181,13 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
|
||||
assert.deepEqual( readdirSync( external ), [ 'sentinel' ] );
|
||||
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: new URL( '../..', import.meta.url ) } );
|
||||
const names = readdirSync( output ).sort();
|
||||
assert.equal( names.length, 40 );
|
||||
assert.equal( names.length, 45 );
|
||||
for ( const name of [
|
||||
'alter-ego-gaming-half-body-384.avif',
|
||||
'alter-ego-gaming-half-body-384.webp',
|
||||
'alter-ego-gaming-half-body-768.avif',
|
||||
'alter-ego-gaming-half-body-768.webp',
|
||||
'alter-ego-gaming-half-body.json',
|
||||
'the-no-names-collage-384.avif',
|
||||
'the-no-names-collage-384.webp',
|
||||
'the-no-names-collage-768.avif',
|
||||
@@ -193,6 +198,7 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
|
||||
}
|
||||
let total = 0;
|
||||
let collageTotal = 0;
|
||||
let gamingHalfBodyTotal = 0;
|
||||
for ( const name of names ) {
|
||||
const generated = readFileSync( join( output, name ) );
|
||||
const committed = readFileSync( new URL( `../../assets/images/generated/${ name }`, import.meta.url ) );
|
||||
@@ -213,10 +219,17 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
|
||||
if ( name.startsWith( 'the-no-names-collage-' ) ) {
|
||||
collageTotal += generated.length;
|
||||
}
|
||||
if ( name.startsWith( 'alter-ego-gaming-half-body-' ) ) {
|
||||
gamingHalfBodyTotal += generated.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.ok( collageTotal <= 400 * 1024, `collage derivatives exceed 400 KiB: ${ collageTotal }` );
|
||||
assert.ok( total <= 2.1 * 1024 * 1024, `derivatives exceed 2.1 MiB: ${ total }` );
|
||||
assert.ok(
|
||||
gamingHalfBodyTotal <= 340 * 1024,
|
||||
`gaming half-body derivatives exceed 340 KiB: ${ gamingHalfBodyTotal }`,
|
||||
);
|
||||
assert.ok( total <= 2.4 * 1024 * 1024, `derivatives exceed 2.4 MiB: ${ total }` );
|
||||
} finally {
|
||||
rmSync( output, { recursive: true, force: true } );
|
||||
rmSync( external, { recursive: true, force: true } );
|
||||
|
||||
Reference in new issue
Block a user