feat: colorize the ui based on the app color

This commit is contained in:
2025-12-28 23:54:23 +01:00
parent 22c9fe2742
commit dafdbdc533
20 changed files with 194 additions and 30 deletions

View File

@@ -9,9 +9,11 @@ const props = withDefaults(
},
);
const app = useAppStore();
const { assets } = useAssets();
const ANIMATION_SPEED = 0.25;
const CORNER_SIZE = 11;
let [currentX, currentY, currentWidth, currentHeight] = props.rect;
@@ -43,21 +45,67 @@ useRender((ctx) => {
ctx.globalAlpha = props.opacity;
ctx.drawImage(assets.common.selectorCorner, x, y);
const spriteY = (app.color.row * 4 + app.color.col) * CORNER_SIZE;
// Top-left corner
ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
x,
y,
CORNER_SIZE,
CORNER_SIZE,
);
// Top-right corner
ctx.save();
ctx.scale(-1, 1);
ctx.drawImage(assets.common.selectorCorner, -(x + w), y);
ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
-(x + w),
y,
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore();
// Bottom-left corner
ctx.save();
ctx.scale(1, -1);
ctx.drawImage(assets.common.selectorCorner, x, -(y + h));
ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
x,
-(y + h),
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore();
// Bottom-right corner
ctx.save();
ctx.scale(-1, -1);
ctx.drawImage(assets.common.selectorCorner, -(x + w), -(y + h));
ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
-(x + w),
-(y + h),
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore();
});