diff --git a/src/js/core/draw_utils.js b/src/js/core/draw_utils.js index 94f7a84b..8e82753b 100644 --- a/src/js/core/draw_utils.js +++ b/src/js/core/draw_utils.js @@ -10,29 +10,6 @@ import { Rectangle } from "./rectangle"; const logger = createLogger("draw_utils"); export function initDrawUtils() { - CanvasRenderingContext2D.prototype.beginRoundedRect = function (x, y, w, h, r) { - this.beginPath(); - - if (r < 0.05) { - this.rect(x, y, w, h); - return; - } - - if (w < 2 * r) { - r = w / 2; - } - - if (h < 2 * r) { - r = h / 2; - } - - this.moveTo(x + r, y); - this.arcTo(x + w, y, x + w, y + h, r); - this.arcTo(x + w, y + h, x, y + h, r); - this.arcTo(x, y + h, x, y, r); - this.arcTo(x, y, x + w, y, r); - }; - CanvasRenderingContext2D.prototype.beginCircle = function (x, y, r) { this.beginPath(); diff --git a/src/js/game/belt_path.js b/src/js/game/belt_path.js index f5112569..dbb298a1 100644 --- a/src/js/game/belt_path.js +++ b/src/js/game/belt_path.js @@ -1321,7 +1321,8 @@ export class BeltPath extends BasicSerializableObject { const nextDistanceAndItem = this.items[i]; const worldPos = this.computePositionFromProgress(progress).toWorldSpaceCenterOfTile(); parameters.context.fillStyle = "#268e4d"; - parameters.context.beginRoundedRect(worldPos.x - 5, worldPos.y - 5, 10, 10, 3); + parameters.context.beginPath(); + parameters.context.roundRect(worldPos.x - 5, worldPos.y - 5, 10, 10, 3); parameters.context.fill(); parameters.context.font = "6px GameFont"; parameters.context.fillStyle = "#111"; diff --git a/src/js/game/hud/parts/building_placer.js b/src/js/game/hud/parts/building_placer.js index 4649b976..776df330 100644 --- a/src/js/game/hud/parts/building_placer.js +++ b/src/js/game/hud/parts/building_placer.js @@ -371,7 +371,8 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic { parameters.context.fillStyle = "rgba(255, 0, 0, 0.2)"; } - parameters.context.beginRoundedRect( + parameters.context.beginPath(); + parameters.context.roundRect( entityBounds.x * globalConfig.tileSize - drawBorder, entityBounds.y * globalConfig.tileSize - drawBorder, entityBounds.w * globalConfig.tileSize + 2 * drawBorder, diff --git a/src/js/game/hud/parts/interactive_tutorial.js b/src/js/game/hud/parts/interactive_tutorial.js index f31d667c..14cffcae 100644 --- a/src/js/game/hud/parts/interactive_tutorial.js +++ b/src/js/game/hud/parts/interactive_tutorial.js @@ -1,23 +1,23 @@ -import { BaseHUDPart } from "../base_hud_part"; -import { clamp, makeDiv, smoothPulse } from "../../../core/utils"; -import { GameRoot } from "../../root"; -import { MinerComponent } from "../../components/miner"; -import { DynamicDomAttach } from "../dynamic_dom_attach"; -import { TrackedState } from "../../../core/tracked_state"; -import { T } from "../../../translations"; -import { enumItemProcessorTypes, ItemProcessorComponent } from "../../components/item_processor"; -import { ShapeItem } from "../../items/shape_item"; -import { WireComponent } from "../../components/wire"; -import { LeverComponent } from "../../components/lever"; -import { DrawParameters } from "../../../core/draw_parameters"; import { globalConfig } from "../../../core/config"; -import { Vector } from "../../../core/vector"; -import { MetaMinerBuilding } from "../../buildings/miner"; +import { DrawParameters } from "../../../core/draw_parameters"; import { gMetaBuildingRegistry } from "../../../core/global_registries"; -import { MetaBeltBuilding } from "../../buildings/belt"; -import { MetaTrashBuilding } from "../../buildings/trash"; +import { TrackedState } from "../../../core/tracked_state"; +import { clamp, makeDiv, smoothPulse } from "../../../core/utils"; +import { Vector } from "../../../core/vector"; import { SOUNDS } from "../../../platform/sound"; +import { T } from "../../../translations"; +import { MetaBeltBuilding } from "../../buildings/belt"; +import { MetaMinerBuilding } from "../../buildings/miner"; +import { MetaTrashBuilding } from "../../buildings/trash"; +import { enumItemProcessorTypes, ItemProcessorComponent } from "../../components/item_processor"; +import { LeverComponent } from "../../components/lever"; +import { MinerComponent } from "../../components/miner"; +import { WireComponent } from "../../components/wire"; +import { ShapeItem } from "../../items/shape_item"; +import { GameRoot } from "../../root"; import { THEME } from "../../theme"; +import { BaseHUDPart } from "../base_hud_part"; +import { DynamicDomAttach } from "../dynamic_dom_attach"; // @todo: Make dictionary const tutorialsByLevel = [ @@ -257,7 +257,8 @@ export class HUDInteractiveTutorial extends BaseHUDPart { parameters.context.fillStyle = "rgba(74, 237, 134, " + (0.5 - animation * 0.2) + ")"; parameters.context.strokeStyle = "rgb(74, 237, 134)"; parameters.context.lineWidth = 2; - parameters.context.beginRoundedRect( + parameters.context.beginPath(); + parameters.context.roundRect( closest.x * globalConfig.tileSize - 2 * animation, closest.y * globalConfig.tileSize - 2 * animation, globalConfig.tileSize + 4 * animation, @@ -423,7 +424,8 @@ export class HUDInteractiveTutorial extends BaseHUDPart { parameters.context.fillStyle = "rgba(74, 237, 134, " + (0.5 - animation * 0.2) + ")"; parameters.context.strokeStyle = "rgb(74, 237, 134)"; parameters.context.lineWidth = 2; - parameters.context.beginRoundedRect( + parameters.context.beginPath(); + parameters.context.roundRect( slot.x - 2 * animation, slot.y - 2 * animation, globalConfig.tileSize + 4 * animation, diff --git a/src/js/game/hud/parts/miner_highlight.js b/src/js/game/hud/parts/miner_highlight.js index 5cf17345..80b4b2a1 100644 --- a/src/js/game/hud/parts/miner_highlight.js +++ b/src/js/game/hud/parts/miner_highlight.js @@ -59,7 +59,8 @@ export class HUDMinerHighlight extends BaseHUDPart { const entity = connectedEntities[i]; const staticComp = entity.components.StaticMapEntity; - parameters.context.beginRoundedRect( + parameters.context.beginPath(); + parameters.context.roundRect( staticComp.origin.x * globalConfig.tileSize + 5, staticComp.origin.y * globalConfig.tileSize + 5, globalConfig.tileSize - 10, @@ -81,7 +82,8 @@ export class HUDMinerHighlight extends BaseHUDPart { // Background parameters.context.fillStyle = THEME.map.connectedMiners.background; - parameters.context.beginRoundedRect( + parameters.context.beginPath(); + parameters.context.roundRect( tooltipLocation.x + 5 * scale, tooltipLocation.y - 3 * scale, (isCapped ? 100 : 65) * scale, diff --git a/src/js/game/hud/parts/waypoints.js b/src/js/game/hud/parts/waypoints.js index 032c0221..f1628054 100644 --- a/src/js/game/hud/parts/waypoints.js +++ b/src/js/game/hud/parts/waypoints.js @@ -589,7 +589,8 @@ export class HUDWaypoints extends BaseHUDPart { // Render the background rectangle parameters.context.globalAlpha = this.currentMarkerOpacity * (isSelected ? 1 : 0.7); parameters.context.fillStyle = "rgba(255, 255, 255, 0.7)"; - parameters.context.beginRoundedRect(bounds.x, bounds.y, bounds.w, bounds.h, 6); + parameters.context.beginPath(); + parameters.context.roundRect(bounds.x, bounds.y, bounds.w, bounds.h, 6); parameters.context.fill(); // Render the text diff --git a/src/js/globals.d.ts b/src/js/globals.d.ts index 07261bf8..86e335f8 100644 --- a/src/js/globals.d.ts +++ b/src/js/globals.d.ts @@ -40,7 +40,6 @@ declare interface ImportMeta { } declare interface CanvasRenderingContext2D { - beginRoundedRect(x: number, y: number, w: number, h: number, r: number): void; beginCircle(x: number, y: number, r: number): void; }