From 23173f24b0392be66a587131cafde95fe73b54aa Mon Sep 17 00:00:00 2001 From: Michael Enion Date: Tue, 11 Jun 2024 12:37:50 -0700 Subject: [PATCH] Add internal PIXI.Point._invertKey method Used when inverting non x,y keys. Such as grid offsets. --- Changelog.md | 1 + PIXI/Point.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 76cabbf..d9e5632 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,6 @@ ## 0.3.4 Handle Wall, Edge classes in Draw.segment. +Add an internal PIXI.Point.invert that returns object, for non-keys. ## 0.3.3 Switch to using TextureLoader.getTextureAlphaData. diff --git a/PIXI/Point.js b/PIXI/Point.js index 86e1f80..a21bbc2 100644 --- a/PIXI/Point.js +++ b/PIXI/Point.js @@ -20,10 +20,15 @@ PIXI.Point._tmp3 = new PIXI.Point(); * @param {number} key Integer key * @returns {PIXI.Point} coordinates */ -function invertKey(key) { +function invertKey(key, outPoint) { + outPoint ??= new this(); + return outPoint.copyFrom(this._invertKey(key)); +} + +function _invertKey(key) { const x = Math.floor(key * MAX_TEXTURE_SIZE_INV); const y = key - (MAX_TEXTURE_SIZE * x); - return new PIXI.Point(x, y); + return { x, y }; } /** @@ -431,7 +436,8 @@ PATCHES.PIXI.STATIC_METHODS = { angleBetween, flatMapPoints, fromObject, - invertKey + invertKey, + _invertKey }; PATCHES.PIXI.METHODS = {