creating a CG text input
This commit is contained in:
parent
12d27a1bff
commit
bc186d658c
6 changed files with 128 additions and 44 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue