{"version":3,"file":"updateQuadBounds.mjs","sources":["../../../src/utils/data/updateQuadBounds.ts"],"sourcesContent":["import type { ObservablePoint } from '../../maths/point/ObservablePoint';\nimport type { Texture } from '../../rendering/renderers/shared/texture/Texture';\nimport type { BoundsData } from '../../scene/container/bounds/Bounds';\n\n/**\n * Updates the bounds of a quad (a rectangular area) based on the provided texture and anchor point.\n *\n * This function calculates the minimum and maximum x and y coordinates of the bounds, taking into\n * account the texture's original dimensions and any trimming that may have been applied to it.\n * @param {BoundsData} bounds - The bounds object to be updated. It contains minX, maxX, minY, and maxY properties.\n * @param {ObservablePoint} anchor - The anchor point of the texture, which affects the positioning of the bounds.\n * @param {Texture} texture - The texture whose dimensions and trimming information are used to update the bounds.\n * @internal\n */\nexport function updateQuadBounds(\n    bounds: BoundsData,\n    anchor: ObservablePoint,\n    texture: Texture\n): void\n{\n    const { width, height } = texture.orig;\n    const trim = texture.trim;\n\n    // If the texture has trimming information, adjust the bounds accordingly\n    if (trim)\n    {\n        // Calculate the source width and height from the trim\n        const sourceWidth = trim.width;\n        const sourceHeight = trim.height;\n\n        // Update the bounds using the trim's x and y offsets and the anchor point\n        bounds.minX = trim.x - (anchor._x * width);\n        bounds.maxX = bounds.minX + sourceWidth;\n\n        bounds.minY = trim.y - (anchor._y * height);\n        bounds.maxY = bounds.minY + sourceHeight;\n    }\n    // If there is no trimming, calculate the bounds based solely on the texture's original dimensions\n    else\n    {\n        bounds.minX = -anchor._x * width;\n        bounds.maxX = bounds.minX + width;\n\n        bounds.minY = -anchor._y * height;\n        bounds.maxY = bounds.minY + height;\n    }\n}\n"],"names":[],"mappings":";AAcO,SAAS,gBAAA,CACZ,MAAA,EACA,MAAA,EACA,OAAA,EAEJ;AACI,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAO,GAAI,OAAA,CAAQ,IAAA;AAClC,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AAGrB,EAAA,IAAI,IAAA,EACJ;AAEI,IAAA,MAAM,cAAc,IAAA,CAAK,KAAA;AACzB,IAAA,MAAM,eAAe,IAAA,CAAK,MAAA;AAG1B,IAAA,MAAA,CAAO,IAAA,GAAO,IAAA,CAAK,CAAA,GAAK,MAAA,CAAO,EAAA,GAAK,KAAA;AACpC,IAAA,MAAA,CAAO,IAAA,GAAO,OAAO,IAAA,GAAO,WAAA;AAE5B,IAAA,MAAA,CAAO,IAAA,GAAO,IAAA,CAAK,CAAA,GAAK,MAAA,CAAO,EAAA,GAAK,MAAA;AACpC,IAAA,MAAA,CAAO,IAAA,GAAO,OAAO,IAAA,GAAO,YAAA;AAAA,EAChC,CAAA,MAGA;AACI,IAAA,MAAA,CAAO,IAAA,GAAO,CAAC,MAAA,CAAO,EAAA,GAAK,KAAA;AAC3B,IAAA,MAAA,CAAO,IAAA,GAAO,OAAO,IAAA,GAAO,KAAA;AAE5B,IAAA,MAAA,CAAO,IAAA,GAAO,CAAC,MAAA,CAAO,EAAA,GAAK,MAAA;AAC3B,IAAA,MAAA,CAAO,IAAA,GAAO,OAAO,IAAA,GAAO,MAAA;AAAA,EAChC;AACJ;;;;"}