From f8bdaf73ea56255e4dc982bf8b87affac0e929a6 Mon Sep 17 00:00:00 2001 From: Reimar Date: Wed, 15 Oct 2025 12:09:58 +0200 Subject: [PATCH] add drawCircle --- src/gamelib.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gamelib.js b/src/gamelib.js index 72b9c1f..90e0e72 100644 --- a/src/gamelib.js +++ b/src/gamelib.js @@ -184,7 +184,6 @@ export class Gamelib { const maxSize = Math.max(sprite.width, sprite.height); const newSprite = new OffscreenCanvas(maxSize, maxSize); - console.log(newSprite); const newSpriteCx = newSprite.getContext("2d"); newSpriteCx.imageSmoothingEnabled = false; @@ -221,6 +220,15 @@ export class Gamelib { cx.fillRect(x, y, width, height); } + drawCircle(x, y, r, color) { + const cx = this.cx; + + cx.fillStyle = color; + cx.beginPath(); + cx.arc(x, y, r, 0, 2 * Math.PI, false); + cx.fill(); + } + drawLine(x0, y0, x1, y1, thickness, color) { const cx = this.cx; @@ -269,8 +277,6 @@ export class Gamelib { .filter((val) => val) .join(" "); - console.log(cx.font); - cx.textAlign = style.align ?? "left"; cx.textBaseline = style.baseline ?? "alphabetic"; cx.direction = style.direction ?? "ltr"; @@ -367,6 +373,10 @@ export class GamelibAdapter { this.gamelib.drawRect(x, y, width, height, color); } + drawCircle(x, y, r, color) { + this.gamelib.drawCircle(x, y, r, color); + } + drawLine(x0, y0, x1, y1, thickness, color) { this.gamelib.drawLine(x0, y0, x1, y1, thickness, color); }