|
|
|
|
@ -27,7 +27,7 @@ export function render(ui: UIValue, canvas: HTMLCanvasElement) {
|
|
|
|
|
function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: number) {
|
|
|
|
|
switch (ui.kind) {
|
|
|
|
|
case 'rect': {
|
|
|
|
|
ctx.fillStyle = ui.color;
|
|
|
|
|
ctx.fillStyle = ui.color || 'transparent';
|
|
|
|
|
|
|
|
|
|
if (ui.radius && ui.radius > 0) {
|
|
|
|
|
const r = Math.min(ui.radius, ui.w / 2, ui.h / 2);
|
|
|
|
|
@ -43,8 +43,21 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
|
|
|
|
|
ctx.arcTo(x, y, x + r, y, r);
|
|
|
|
|
ctx.closePath();
|
|
|
|
|
ctx.fill();
|
|
|
|
|
|
|
|
|
|
if (ui.strokeColor && ui.strokeWidth) {
|
|
|
|
|
ctx.strokeStyle = ui.strokeColor;
|
|
|
|
|
ctx.lineWidth = ui.strokeWidth;
|
|
|
|
|
ctx.stroke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
ctx.fillRect(x, y, ui.w, ui.h);
|
|
|
|
|
|
|
|
|
|
if (ui.strokeColor && ui.strokeWidth) {
|
|
|
|
|
ctx.strokeStyle = ui.strokeColor;
|
|
|
|
|
ctx.lineWidth = ui.strokeWidth;
|
|
|
|
|
ctx.strokeRect(x, y, ui.w, ui.h);;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
@ -53,7 +66,7 @@ function renderUI(ui: UIValue, ctx: CanvasRenderingContext2D, x: number, y: numb
|
|
|
|
|
case 'text':
|
|
|
|
|
ctx.fillStyle = 'black';
|
|
|
|
|
ctx.font = '16px "SF Mono", "Monaco", "Menlo", "Consolas", "Courier New", monospace';
|
|
|
|
|
ctx.fillText(ui.content, x + ui.x, y + ui.y);
|
|
|
|
|
ctx.fillText(ui.content, x, y);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'row': {
|
|
|
|
|
|