Files
nothoughts/node_modules/pixi.js/lib/scene/sprite-nine-slice/NineSliceGeometry.mjs.map
2025-08-04 18:57:35 +02:00

1 line
9.1 KiB
Plaintext

{"version":3,"file":"NineSliceGeometry.mjs","sources":["../../../src/scene/sprite-nine-slice/NineSliceGeometry.ts"],"sourcesContent":["import { PlaneGeometry } from '../mesh-plane/PlaneGeometry';\n\n/**\n * Options for the NineSliceGeometry.\n * @memberof scene\n */\nexport interface NineSliceGeometryOptions\n{\n\n /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n width?: number\n /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n height?: number\n /** The original width of the texture */\n originalWidth?: number\n /** The original height of the texture */\n originalHeight?: number\n /** The width of the left column. */\n leftWidth?: number\n /** The height of the top row. */\n topHeight?: number\n /** The width of the right column. */\n rightWidth?: number\n /** The height of the bottom row. */\n bottomHeight?: number\n}\n\n/**\n * The NineSliceGeometry class allows you to create a NineSlicePlane object.\n * @memberof scene\n */\nexport class NineSliceGeometry extends PlaneGeometry\n{\n /** The default options for the NineSliceGeometry. */\n public static defaultOptions: NineSliceGeometryOptions = {\n /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n width: 100,\n /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n height: 100,\n /** The width of the left column. */\n leftWidth: 10,\n /** The height of the top row. */\n topHeight: 10,\n /** The width of the right column. */\n rightWidth: 10,\n /** The height of the bottom row. */\n bottomHeight: 10,\n\n /** The original width of the texture */\n originalWidth: 100,\n /** The original height of the texture */\n originalHeight: 100,\n };\n\n public _leftWidth: number;\n public _rightWidth: number;\n public _topHeight: number;\n public _bottomHeight: number;\n\n private _originalWidth: number;\n private _originalHeight: number;\n\n constructor(options: NineSliceGeometryOptions = {})\n {\n options = { ...NineSliceGeometry.defaultOptions, ...options };\n\n super({\n width: options.width,\n height: options.height,\n verticesX: 4,\n verticesY: 4,\n });\n\n this.update(options);\n }\n\n /**\n * Updates the NineSliceGeometry with the options.\n * @param options - The options of the NineSliceGeometry.\n */\n public update(options: NineSliceGeometryOptions)\n {\n this.width = options.width ?? this.width;\n this.height = options.height ?? this.height;\n this._originalWidth = options.originalWidth ?? this._originalWidth;\n this._originalHeight = options.originalHeight ?? this._originalHeight;\n this._leftWidth = options.leftWidth ?? this._leftWidth;\n this._rightWidth = options.rightWidth ?? this._rightWidth;\n this._topHeight = options.topHeight ?? this._topHeight;\n this._bottomHeight = options.bottomHeight ?? this._bottomHeight;\n\n this.updateUvs();\n this.updatePositions();\n }\n\n /** Updates the positions of the vertices. */\n public updatePositions()\n {\n const positions = this.positions;\n\n const w = this._leftWidth + this._rightWidth;\n const scaleW = this.width > w ? 1.0 : this.width / w;\n\n const h = this._topHeight + this._bottomHeight;\n const scaleH = this.height > h ? 1.0 : this.height / h;\n\n const scale = Math.min(scaleW, scaleH);\n\n positions[9] = positions[11] = positions[13] = positions[15] = this._topHeight * scale;\n positions[17] = positions[19] = positions[21] = positions[23] = this.height - (this._bottomHeight * scale);\n positions[25] = positions[27] = positions[29] = positions[31] = this.height;\n\n positions[2] = positions[10] = positions[18] = positions[26] = this._leftWidth * scale;\n positions[4] = positions[12] = positions[20] = positions[28] = this.width - (this._rightWidth * scale);\n positions[6] = positions[14] = positions[22] = positions[30] = this.width;\n\n this.getBuffer('aPosition').update();\n }\n\n /** Updates the UVs of the vertices. */\n public updateUvs()\n {\n const uvs = this.uvs;\n\n uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;\n uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;\n\n uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1;\n uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;\n\n const _uvw = 1.0 / this._originalWidth;\n const _uvh = 1.0 / this._originalHeight;\n\n uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;\n uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight;\n\n uvs[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