add strokeRect, strokeRect

This commit is contained in:
sfj 2025-09-08 13:37:59 +02:00
parent 4130c45449
commit 457931b28d

View File

@ -30,6 +30,34 @@ export function fillRect(x, y, width, height, color) {
ctx.fillRect(x, y, width, height);
}
/**
* Draw a rectangle outline.
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @param {string} color
*/
export function strokeRect(x, y, width, height, color) {
ctx.strokeStyle = color;
ctx.lineWidth = 1;
ctx.strokeRect(x, y, width, height);
}
/**
*
* @param {string} text
* @param {number} x
* @param {number} y
* @param {string} color
*/
export function putText(text, x, y, color) {
const fontSize = 24;
ctx.fillStyle = color;
ctx.font = `bold ${fontSize}px monospace`;
ctx.fillText(text, x, y + fontSize);
}
/**
*
* @param {Texture} texture