From 06701105932d2f4e1606e3e34efdcff19890b9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Sat, 14 Jun 2025 04:43:19 +0300 Subject: [PATCH] Move beginCircle to polyfills.ts Technically not a polyfill, but neither are two existing functions in polyfills.ts. --- src/js/core/draw_utils.js | 13 ------------- src/js/core/polyfills.ts | 12 ++++++++++++ src/js/main.js | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/js/core/draw_utils.js b/src/js/core/draw_utils.js index 8e82753b..93652d11 100644 --- a/src/js/core/draw_utils.js +++ b/src/js/core/draw_utils.js @@ -9,19 +9,6 @@ import { Rectangle } from "./rectangle"; const logger = createLogger("draw_utils"); -export function initDrawUtils() { - CanvasRenderingContext2D.prototype.beginCircle = function (x, y, r) { - this.beginPath(); - - if (r < 0.05) { - this.rect(x, y, 1, 1); - return; - } - - this.arc(x, y, r, 0, 2.0 * Math.PI); - }; -} - /** * * @param {object} param0 diff --git a/src/js/core/polyfills.ts b/src/js/core/polyfills.ts index 0467e50f..e9a2bd28 100644 --- a/src/js/core/polyfills.ts +++ b/src/js/core/polyfills.ts @@ -7,3 +7,15 @@ Math.radians = function (degrees: number): number { Math.degrees = function (radians: number): number { return (radians * 180.0) / Math.PI; }; + +// Begins a path and draws a circle. +CanvasRenderingContext2D.prototype.beginCircle = function (x: number, y: number, r: number): void { + this.beginPath(); + + if (r < 0.05) { + this.rect(x, y, 1, 1); + return; + } + + this.arc(x, y, r, 0, 2.0 * Math.PI); +}; diff --git a/src/js/main.js b/src/js/main.js index 1a85c922..9ba474cf 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -5,7 +5,6 @@ import "./mods/modloader"; import { Application } from "./application"; import { IS_DEBUG } from "./core/config"; -import { initDrawUtils } from "./core/draw_utils"; import { createLogger, logSection } from "./core/logging"; import { initComponentRegistry } from "./game/component_registry"; import { initGameModeRegistry } from "./game/game_mode_registry"; @@ -43,7 +42,6 @@ console.log("%cDEVCODE BUILT IN", "color: #f77"); logSection("Boot Process", "#f9a825"); -initDrawUtils(); initComponentRegistry(); initItemRegistry(); initMetaBuildingRegistry();