Adding Opacity ui primitive
This commit is contained in:
parent
441957185e
commit
12d27a1bff
3 changed files with 18 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue