Adding Opacity ui primitive

This commit is contained in:
Dustin Swan 2026-02-03 14:28:39 -07:00
parent 441957185e
commit 12d27a1bff
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 18 additions and 0 deletions

View file

@ -98,6 +98,14 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
renderUI(ui.child, ctx, x + ui.amount, y + ui.amount);
break;
case 'opacity': {
const previousAlpha = ctx.globalAlpha;
ctx.globalAlpha = previousAlpha * ui.opacity;
renderUI(ui.child, ctx, x, y);
ctx.globalAlpha = previousAlpha;
break;
}
case 'stack': {
for (const child of ui.children) {
renderUI(child, ctx, x, y);