1 line
36 KiB
Plaintext
1 line
36 KiB
Plaintext
|
|
{"version":3,"file":"GraphicsGeometry.mjs","sources":["../src/GraphicsGeometry.ts"],"sourcesContent":["import {\n BaseTexture,\n BatchDrawCall,\n BatchGeometry,\n BatchTextureArray,\n Color,\n DRAW_MODES,\n Point,\n WRAP_MODES\n} from '@pixi/core';\nimport { Bounds } from '@pixi/display';\nimport { GraphicsData } from './GraphicsData';\nimport {\n BATCH_POOL, BatchPart, buildLine,\n buildPoly,\n DRAW_CALL_POOL,\n FILL_COMMANDS\n} from './utils';\n\nimport type { IPointData, IShape, Matrix, Texture } from '@pixi/core';\nimport type { FillStyle } from './styles/FillStyle';\nimport type { LineStyle } from './styles/LineStyle';\n\nconst tmpPoint = new Point();\n\n/**\n * The Graphics class contains methods used to draw primitive shapes such as lines, circles and\n * rectangles to the display, and to color and fill them.\n *\n * GraphicsGeometry is designed to not be continually updating the geometry since it's expensive\n * to re-tesselate using **earcut**. Consider using {@link PIXI.Mesh} for this use-case, it's much faster.\n * @memberof PIXI\n */\nexport class GraphicsGeometry extends BatchGeometry\n{\n /** The maximum number of points to consider an object \"batchable\", able to be batched by the renderer's batch system. */\n public static BATCHABLE_SIZE = 100;\n\n /** Minimal distance between points that are considered different. Affects line tesselation. */\n public closePointEps = 1e-4;\n\n /** Padding to add to the bounds. */\n public boundsPadding = 0;\n\n uvsFloat32: Float32Array = null;\n indicesUint16: Uint16Array | Uint32Array = null;\n batchable = false;\n\n /** An array of points to draw, 2 numbers per point */\n points: number[] = [];\n\n /** The collection of colors */\n colors: number[] = [];\n\n /** The UVs collection */\n uvs: number[] = [];\n\n /** The indices of the vertices */\n indices: number[] = [];\n\n /** Reference to the texture IDs. */\n textureIds: number[] = [];\n\n /**\n * The collection of drawn shapes.\n * @member {PIXI.GraphicsData[]}\n */\n graphicsData: Array<GraphicsData> = [];\n\n /**\n * List of current draw calls drived from the batches.\n * @member {PIXI.BatchDrawCall[]}\n */\n drawCalls: Array<BatchDrawCall> = [];\n\n /** Batches need to regenerated if the geometry is updated. */\n batchDirty = -1;\n\n /**\n * Intermediate abstract format sent to batch system.\n * Can be converted to drawCalls or to batchable objects.\n * @member {PIXI.graphicsUtils.BatchPart[]}\n */\n batches: Array<BatchPart> = [];\n\n /** Used to detect if the graphics object has changed. */\n protected dirty = 0;\n\n /** Used to check if the cache is dirty. */\n protected cacheDirty = -1;\n\n /** Used to detect if we cleared the graphicsData. */\n protected clearDirty = 0;\n\n /** Index of the last batched shape in the stack of calls. */\n protected shapeIndex = 0;\n\n /** Cached bounds. */\n protected _bounds: Bounds = new Bounds();\n\n /** The bounds dirty flag. */\n protected boundsDirty = -1;\n\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor()\n {\n super();\n }\n\n /**\n * Get the current bounds of the graphic geometry.\n *\n * Since 6.5.0, bounds of the graphics geometry are calculated based on the vertices of generated geometry.\n * Since shapes or strokes with full transparency (`alpha: 0`) will not generate geometry, they are not considered\n * when calculating bounds for the graphics geometry. See PR [#8343]{@link https://github.com/pixijs/pixijs/pull/8343}\n * and issue [#8623]{@link https://github.com/pixijs/pixijs/pull/8623}.\n * @readonly\n */\n public get bounds(): Bounds\n {\n this.updateBatches();\n\n if (this.boundsDirty !== this.dirty)\n {\n this.boundsDirty = this.dirty;\n this.calculateBounds();\n }\n\n return this._bounds;\n }\n\n /** Call i
|