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 = {