- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
import type { Matrix, SHAPES, IShape } from '@pixi/math';
import type { FillStyle } from './styles/FillStyle';
import type { LineStyle } from './styles/LineStyle';
/**
* A class to contain data useful for Graphics objects
* @memberof PIXI
*/
export class GraphicsData
{
/**
* The shape object to draw.
* @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle}
*/
shape: IShape;
/** The style of the line. */
lineStyle: LineStyle;
/** The style of the fill. */
fillStyle: FillStyle;
/** The transform matrix. */
matrix: Matrix;
/** The type of the shape, see the Const.Shapes file for all the existing types, */
type: SHAPES;
/** The collection of points. */
points: number[] = [];
/** The collection of holes. */
holes: Array<GraphicsData> = [];
/**
* @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.
* @param fillStyle - the width of the line to draw
* @param lineStyle - the color of the line to draw
* @param matrix - Transform matrix
*/
constructor(shape: IShape, fillStyle: FillStyle = null, lineStyle: LineStyle = null, matrix: Matrix = null)
{
this.shape = shape;
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
this.matrix = matrix;
this.type = shape.type;
}
/**
* Creates a new GraphicsData object with the same values as this one.
* @returns - Cloned GraphicsData object
*/
public clone(): GraphicsData
{
return new GraphicsData(
this.shape,
this.fillStyle,
this.lineStyle,
this.matrix
);
}
/** Destroys the Graphics data. */
public destroy(): void
{
this.shape = null;
this.holes.length = 0;
this.holes = null;
this.points.length = 0;
this.points = null;
this.lineStyle = null;
this.fillStyle = null;
}
}