Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/sprite-tiling/lib/TilingSprite.mjs.map

1 line
11 KiB
Plaintext
Raw Normal View History

2025-01-04 00:34:03 +01:00
{"version":3,"file":"TilingSprite.mjs","sources":["../src/TilingSprite.ts"],"sourcesContent":["import { Point, Rectangle, Texture, TextureMatrix, Transform } from '@pixi/core';\nimport { Sprite } from '@pixi/sprite';\n\nimport type { IBaseTextureOptions, IPoint, IPointData, ISize, ObservablePoint, Renderer, TextureSource } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\n\nconst tempPoint = new Point();\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface TilingSprite extends GlobalMixins.TilingSprite {}\n\n/**\n * A tiling sprite is a fast way of rendering a tiling image.\n * @memberof PIXI\n */\nexport class TilingSprite extends Sprite\n{\n /** Tile transform */\n public tileTransform: Transform;\n\n /** Matrix that is applied to UV to get the coords in Texture normalized space to coords in BaseTexture space. */\n public uvMatrix: TextureMatrix;\n\n /**\n * Flags whether the tiling pattern should originate from the origin instead of the top-left corner in\n * local space.\n *\n * This will make the texture coordinates assigned to each vertex dependent on the value of the anchor. Without\n * this, the top-left corner always gets the (0, 0) texture coordinate.\n * @default false\n */\n public uvRespectAnchor: boolean;\n\n /**\n * Note: The wrap mode of the texture is forced to REPEAT on render if the size of the texture\n * is a power of two, the texture's wrap mode is CLAMP, and the texture hasn't been bound yet.\n * @param texture - The texture of the tiling sprite.\n * @param width - The width of the tiling sprite.\n * @param height - The height of the tiling sprite.\n */\n constructor(texture: Texture, width = 100, height = 100)\n {\n super(texture);\n\n this.tileTransform = new Transform();\n\n // The width of the tiling sprite\n this._width = width;\n\n // The height of the tiling sprite\n this._height = height;\n\n this.uvMatrix = this.texture.uvMatrix || new TextureMatrix(texture);\n\n /**\n * Plugin that is responsible for rendering this element.\n * Allows to customize the rendering process without overriding '_render' method.\n * @default 'tilingSprite'\n */\n this.pluginName = 'tilingSprite';\n\n this.uvRespectAnchor = false;\n }\n /**\n * Changes frame clamping in corresponding textureTransform, shortcut\n * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas\n * @default 0.5\n * @member {number}\n */\n get clampMargin(): number\n {\n return this.uvMatrix.clampMargin;\n }\n\n set clampMargin(value: number)\n {\n this.uvMatrix.clampMargin = value;\n this.uvMatrix.update(true);\n }\n\n /** The scaling of the image that is being tiled. */\n get tileScale(): ObservablePoint\n {\n return this.tileTransform.scale;\n }\n\n set tileScale(value: IPointData)\n {\n this.tileTransform.scale.copyFrom(value as IPoint);\n }\n\n /** The offset of the image that is being tiled. */\n get tilePosition(): ObservablePoint\n {\n return this.tileTransform.position;\n }\n\n set tilePosition(value: ObservablePoint)\n {\n this.tileTransform.position.copyFrom(value as IPoint);\n }\n\n /**\n * @protected\n */\n protected _onTextureUpdate(): void\n {\n if (this.uvMatrix)\n {\n this.uvMatrix.texture = this._texture;\n }\n this._cachedTint = 0xFFFFFF;\n }\n\n /**\n * Renders the object using the WebGL renderer\n * @param renderer - The renderer\n */\n protected _render(renderer: Renderer): void\n {\n // tweak our texture temporarily..\n const texture = this._texture;\n\n if (!texture || !texture.valid)\n {\n return;\n }\n\n this.tileTransform.updateLocalTransform();\n this.uvMatrix.updat