Adding Clip ui primitive. text boxes looking... well, still awful but getting there

This commit is contained in:
Dustin Swan 2026-02-03 23:12:30 -07:00
parent 4626616b14
commit 787e071fbd
No known key found for this signature in database
GPG key ID: 30D46587E2100467
4 changed files with 49 additions and 19 deletions

View file

@ -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 {