creating a CG text input

This commit is contained in:
Dustin Swan 2026-02-03 18:02:19 -07:00
parent 12d27a1bff
commit bc186d658c
No known key found for this signature in database
GPG key ID: 30D46587E2100467
6 changed files with 128 additions and 44 deletions

View file

@ -65,7 +65,7 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
case 'text':
ctx.fillStyle = 'black';
ctx.font = '16px monospace';
ctx.font = '16px "Courier New", monospace';
ctx.fillText(ui.content, x + ui.x, y + ui.y);
break;
@ -98,6 +98,10 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
renderUI(ui.child, ctx, x + ui.amount, y + ui.amount);
break;
case 'positioned':
renderUI(ui.child, ctx, x + ui.x, y + ui.y);
break;
case 'opacity': {
const previousAlpha = ctx.globalAlpha;
ctx.globalAlpha = previousAlpha * ui.opacity;
@ -188,6 +192,9 @@ function measure(ui: UIValue): { width: number, height: number } {
}
}
case 'positioned':
return measure(ui.child);
case 'stack': {
let maxWidth = 0;
let maxHeight = 0;