feat(assets): use single texture atlas instead of loading all images individually

This commit is contained in:
2026-01-08 19:55:43 +01:00
parent c6d5911b7d
commit e2d40a4bc1
41 changed files with 488 additions and 377 deletions

View File

@@ -56,7 +56,7 @@ const drawTextWithShadow2Lines = (
};
onRender((ctx) => {
ctx.drawImage(assets.projects.topScreen.background, 0, 0);
assets.images.projects.topScreen.background.draw(ctx, 0, 0);
ctx.textBaseline = "hanging";
ctx.font = "16px Pokemon DP Pro";
@@ -80,19 +80,19 @@ onRender((ctx) => {
const offsetFromCurrent = i - store.currentProject;
// TODO: project.id should be typed from useAssets, shouldn't be just a string
const thumbnailImage =
assets.projects.pokemons[
store.projects[i]!.id as keyof typeof assets.projects.pokemons
assets.images.projects.pokemons[
store.projects[i]!.id as keyof typeof assets.images.projects.pokemons
]!;
ctx.drawImage(
thumbnailImage,
thumbnailImage.draw(
ctx,
Math.floor(
thumbnailCenterX +
offsetFromCurrent * thumbnailSpacing -
thumbnailImage.width / 2 +
thumbnailImage.rect.width / 2 +
store.offsetX,
),
Math.floor(thumbnailCenterY - thumbnailImage.height / 2),
Math.floor(thumbnailCenterY - thumbnailImage.rect.height / 2),
);
}