From 1ff76e0b2eb17f2c7548d36ab63126e7c89d7db4 Mon Sep 17 00:00:00 2001 From: Bjorn Stromberg Date: Tue, 18 Aug 2020 21:19:25 +0900 Subject: [PATCH] [core/rectangle] Remove unused methods (#571) * [core/rectangle] Remove unused methods * Restore some methods --- src/js/core/rectangle.js | 53 +--------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/src/js/core/rectangle.js b/src/js/core/rectangle.js index 1cbfdc27..f17825ca 100644 --- a/src/js/core/rectangle.js +++ b/src/js/core/rectangle.js @@ -53,27 +53,6 @@ export class Rectangle { return a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom; } - /** - * Returns a rectangle arround a rotated point - * @param {Array} points - * @param {number} angle - * @returns {Rectangle} - */ - static getAroundPointsRotated(points, angle) { - let minX = 1e10; - let minY = 1e10; - let maxX = -1e10; - let maxY = -1e10; - for (let i = 0; i < points.length; ++i) { - const rotated = points[i].rotated(angle); - minX = Math.min(minX, rotated.x); - minY = Math.min(minY, rotated.y); - maxX = Math.max(maxX, rotated.x); - maxY = Math.max(maxY, rotated.y); - } - return new Rectangle(minX, minY, maxX - minX, maxY - minY); - } - /** * Copies this instance * @returns {Rectangle} @@ -82,28 +61,6 @@ export class Rectangle { return new Rectangle(this.x, this.y, this.w, this.h); } - /** - * Ensures the rectangle contains the given square - * @param {number} centerX - * @param {number} centerY - * @param {number} halfWidth - * @param {number} halfHeight - */ - extendBySquare(centerX, centerY, halfWidth, halfHeight) { - if (this.isEmpty()) { - // Just assign values since this rectangle is empty - this.x = centerX - halfWidth; - this.y = centerY - halfHeight; - this.w = halfWidth * 2; - this.h = halfHeight * 2; - } else { - this.setLeft(Math.min(this.x, centerX - halfWidth)); - this.setRight(Math.max(this.right(), centerX + halfWidth)); - this.setTop(Math.min(this.y, centerY - halfHeight)); - this.setBottom(Math.max(this.bottom(), centerY + halfHeight)); - } - } - /** * Returns if this rectangle is empty * @returns {boolean} @@ -259,14 +216,6 @@ export class Rectangle { return new Rectangle(this.x - amount, this.y - amount, this.w + 2 * amount, this.h + 2 * amount); } - /** - * Helper for computing a culling area. Returns the top left tile - * @returns {Vector} - */ - getMinStartTile() { - return new Vector(this.x, this.y).snapWorldToTile(); - } - /** * Returns if the given rectangle is contained * @param {Rectangle} rect @@ -394,7 +343,7 @@ export class Rectangle { } /** - * Returns a new recangle in tile space which includes all tiles which are visible in this rect + * Returns a new rectangle in tile space which includes all tiles which are visible in this rect * @returns {Rectangle} */ toTileCullRectangle() {