pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 2.29 kB
Source Map (JSON)
{"version":3,"file":"updateTextBounds.mjs","sources":["../../../../src/scene/text/utils/updateTextBounds.ts"],"sourcesContent":["import { updateQuadBounds } from '../../../utils/data/updateQuadBounds';\nimport { type BatchableSprite } from '../../sprite/BatchableSprite';\nimport { type AbstractText } from '../AbstractText';\nimport { type TextStyle, type TextStyleOptions } from '../TextStyle';\n\n/**\n * Updates the bounds of the given batchable sprite based on the provided text object.\n *\n * This function adjusts the bounds of the batchable sprite to match the dimensions\n * and anchor point of the text's texture. Additionally, it compensates for any padding\n * specified in the text's style to ensure the text is rendered correctly on screen.\n * @param {BatchableSprite} batchableSprite - The sprite whose bounds need to be updated.\n * @param {AbstractText} text - The text object containing the texture and style information.\n * @internal\n */\nexport function updateTextBounds(batchableSprite: BatchableSprite, text: AbstractText<TextStyle, TextStyleOptions>)\n{\n const { texture, bounds } = batchableSprite;\n\n updateQuadBounds(bounds, text._anchor, texture);\n\n const padding = text._style._getFinalPadding();\n\n // When HTML text textures are created, they include the padding around the text content\n // to prevent text clipping and provide a buffer zone. This padding is built into\n // the texture itself. However, we don't want this padding to affect the text's\n // actual position on screen.\n // To compensate, we shift the render position back by the padding amount,\n // ensuring the text appears exactly where intended while maintaining the\n // buffer zone around it.\n\n bounds.minX -= padding;\n bounds.minY -= padding;\n bounds.maxX -= padding;\n bounds.maxY -= padding;\n}\n"],"names":[],"mappings":";;;AAegB,SAAA,gBAAA,CAAiB,iBAAkC,IACnE,EAAA;AACI,EAAM,MAAA,EAAE,OAAS,EAAA,MAAA,EAAW,GAAA,eAAA,CAAA;AAE5B,EAAiB,gBAAA,CAAA,MAAA,EAAQ,IAAK,CAAA,OAAA,EAAS,OAAO,CAAA,CAAA;AAE9C,EAAM,MAAA,OAAA,GAAU,IAAK,CAAA,MAAA,CAAO,gBAAiB,EAAA,CAAA;AAU7C,EAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAA;AACf,EAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAA;AACf,EAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAA;AACf,EAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAA;AACnB;;;;"}