Adding Clip ui primitive. text boxes looking... well, still awful but getting there
This commit is contained in:
parent
4626616b14
commit
787e071fbd
4 changed files with 49 additions and 19 deletions
16
src/ui.ts
16
src/ui.ts
|
|
@ -110,6 +110,16 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
|
|||
break;
|
||||
}
|
||||
|
||||
case 'clip': {
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.rect(x, y, ui.w, ui.h);
|
||||
ctx.clip();
|
||||
renderUI(ui.child, ctx, x, y);
|
||||
ctx.restore();
|
||||
break;
|
||||
}
|
||||
|
||||
case 'stack': {
|
||||
for (const child of ui.children) {
|
||||
renderUI(child, ctx, x, y);
|
||||
|
|
@ -184,6 +194,12 @@ function measure(ui: UIValue): { width: number, height: number } {
|
|||
case 'clickable':
|
||||
return measure(ui.child);
|
||||
|
||||
case 'opacity':
|
||||
return measure(ui.child);
|
||||
|
||||
case 'clip':
|
||||
return { width: ui.w, height: ui.h };
|
||||
|
||||
case 'padding': {
|
||||
const childSize = measure(ui.child);
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue