PIXI.GraphicsGeometry
class GraphicsGeometry extends PIXI.BatchGeometry
The Graphics class contains methods used to draw primitive shapes such as lines, circles and rectangles to the display, and to color and fill them.
GraphicsGeometry is designed to not be continually updating the geometry since it's expensive to re-tesselate using earcut. Consider using PIXI.Mesh for this use-case, it's much faster.
Summary
Properties from GraphicsGeometry
number |
|
number |
Batches need to regenerated if the geometry is updated. |
Array<PIXI.graphicsUtils.BatchPart> |
|
PIXI.Bounds |
|
number |
Padding to add to the bounds. |
number |
Minimal distance between points that are considered different. Affects line tesselation. |
number[] |
The collection of colors |
Array<PIXI.BatchDrawCall> |
|
Array<PIXI.GraphicsData> |
|
number[] |
The indices of the vertices |
number[] |
An array of points to draw, 2 numbers per point |
number[] |
Reference to the texture IDs. |
number[] |
The UVs collection |
PIXI.Bounds |
Cached bounds. |
number |
The bounds dirty flag. |
number |
Used to check if the cache is dirty. |
number |
Used to detect if we cleared the graphicsData. |
number |
Used to detect if the graphics object has changed. |
number |
Index of the last batched shape in the stack of calls. |
Methods from GraphicsGeometry
Properties inherited from BatchGeometry
Properties inherited from Geometry
object |
|
number |
|
boolean |
Whether the geometry is instanced. |
number |
Count of existing (not destroyed) meshes that reference this geometry. |
Methods inherited from Geometry
this |
|
PIXI.Geometry |
|
PIXI.Geometry |
|
void |
Disposes WebGL resources that are connected to this geometry. |
PIXI.Attribute |
|
PIXI.Buffer |
|
PIXI.Buffer |
|
number |
Get the size of the geometries, in vertices. |
PIXI.Geometry |
|
Public Properties
static BATCHABLE_SIZE: number = 100
The maximum number of points to consider an object "batchable", able to be batched by the renderer's batch system. \
batchDirty: number = -1
Batches need to regenerated if the geometry is updated.
batches: Array<PIXI.graphicsUtils.BatchPart>
Intermediate abstract format sent to batch system. Can be converted to drawCalls or to batchable objects.
closePointEps: number = 0.0001
Minimal distance between points that are considered different. Affects line tesselation.
drawCalls: Array<PIXI.BatchDrawCall>
List of current draw calls drived from the batches.
graphicsData: Array<PIXI.GraphicsData>
The collection of drawn shapes.
Protected Properties
protected cacheDirty: number = -1
Used to check if the cache is dirty.
protected clearDirty: number = 0
Used to detect if we cleared the graphicsData.
protected dirty: number = 0
Used to detect if the graphics object has changed.
protected shapeIndex: number = 0
Index of the last batched shape in the stack of calls.
Public Methods
clear() → {PIXI.GraphicsGeometry}
Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
Type | Description |
---|---|
PIXI.GraphicsGeometry |
|
containsPoint(point: IPointData) → {boolean}
Check to see if a point is contained within this geometry.
Name | Type | Description |
---|---|---|
point | IPointData |
Point to check if it's contained. |
Type | Description |
---|---|
boolean |
|
destroy() → {void}
Destroys the GraphicsGeometry object.
Type | Description |
---|---|
void |
drawHole(shape: PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle, matrix: PIXI.Matrix) → {PIXI.GraphicsGeometry}
Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
Name | Type | Default | Description |
---|---|---|---|
shape | PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle |
The shape object to draw. |
|
matrix | PIXI.Matrix | undefined |
Transform applied to the points of the shape. |
Type | Description |
---|---|
PIXI.GraphicsGeometry |
|
drawShape(shape: PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle, fillStyle: PIXI.FillStyle, lineStyle: PIXI.LineStyle, matrix: PIXI.Matrix) → {PIXI.GraphicsGeometry}
Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
Name | Type | Default | Description |
---|---|---|---|
shape | PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle |
The shape object to draw. |
|
fillStyle | PIXI.FillStyle | undefined |
Defines style of the fill. |
lineStyle | PIXI.LineStyle | undefined |
Defines style of the lines. |
matrix | PIXI.Matrix | undefined |
Transform applied to the points of the shape. |
Type | Description |
---|---|
PIXI.GraphicsGeometry |
|
updateBatches() → {void}
Generates intermediate batch data. Either gets converted to drawCalls or used to convert to batch objects directly by the Graphics object.
Type | Description |
---|---|
void |
Protected Methods
protected _compareStyles(styleA: PIXI.FillStyle | PIXI.LineStyle, styleB: PIXI.FillStyle | PIXI.LineStyle) → {boolean}
Affinity check
Name | Type | Description |
---|---|---|
styleA | PIXI.FillStyle | PIXI.LineStyle | |
styleB | PIXI.FillStyle | PIXI.LineStyle |
Type | Description |
---|---|
boolean |
protected addColors(colors: Array<number>, color: number, alpha: number, size: number, offset: number) → {void}
Add colors.
Name | Type | Default | Description |
---|---|---|---|
colors | Array<number> |
List of colors to add to |
|
color | number |
Color to add |
|
alpha | number |
Alpha to use |
|
size | number |
Number of colors to add |
|
offset | number | 0 |
Type | Description |
---|---|
void |
protected addTextureIds(textureIds: Array<number>, id: number, size: number, offset: number) → {void}
Add texture id that the shader/fragment wants to use.
Name | Type | Default | Description |
---|---|---|---|
textureIds | Array<number> | ||
id | number | ||
size | number | ||
offset | number | 0 |
Type | Description |
---|---|
void |
protected addUvs(verts: Array<number>, uvs: Array<number>, texture: PIXI.Texture, start: number, size: number, matrix: PIXI.Matrix) → {void}
Generates the UVs for a shape.
Name | Type | Default | Description |
---|---|---|---|
verts | Array<number> |
Vertices |
|
uvs | Array<number> |
UVs |
|
texture | PIXI.Texture |
Reference to Texture |
|
start | number |
Index buffer start index. |
|
size | number |
The size/length for index buffer. |
|
matrix | PIXI.Matrix | undefined |
Optional transform for all points. |
Type | Description |
---|---|
void |
protected adjustUvs(uvs: Array<number>, texture: PIXI.Texture, start: number, size: number) → {void}
Modify uvs array according to position of texture region Does not work with rotated or trimmed textures
Name | Type | Description |
---|---|---|
uvs | Array<number> |
array |
texture | PIXI.Texture |
region |
start | number |
starting index for uvs |
size | number |
how many points to adjust |
Type | Description |
---|---|
void |
protected buildDrawCalls() → {void}
Converts intermediate batches data to drawCalls.
Type | Description |
---|---|
void |
protected calculateBounds() → {void}
Update the local bounds of the object. Expensive to use performance-wise.
Type | Description |
---|---|
void |
protected invalidate() → {void}
Call if you changed graphicsData manually. Empties all batch buffers.
Type | Description |
---|---|
void |
protected isBatchable() → {boolean}
Checks to see if this graphics geometry can be batched. Currently it needs to be small enough and not contain any native lines.
Type | Description |
---|---|
boolean |
protected packAttributes() → {void}
Packs attributes to single buffer.
Type | Description |
---|---|
void |
protected packBatches() → {void}
Offset the indices so that it works with the batcher.
Type | Description |
---|---|
void |
protected processFill(data: PIXI.GraphicsData) → {void}
Process fill part of Graphics.
Name | Type | Description |
---|---|---|
data | PIXI.GraphicsData |
Type | Description |
---|---|
void |
protected processHoles(holes: Array<PIXI.GraphicsData>) → {void}
Process the holes data.
Name | Type | Description |
---|---|---|
holes | Array<PIXI.GraphicsData> |
Type | Description |
---|---|
void |
protected processLine(data: PIXI.GraphicsData) → {void}
Process line part of Graphics.
Name | Type | Description |
---|---|---|
data | PIXI.GraphicsData |
Type | Description |
---|---|
void |
protected transformPoints(points: Array<number>, matrix: PIXI.Matrix) → {void}
Transform points using matrix.
Name | Type | Description |
---|---|---|
points | Array<number> |
Points to transform |
matrix | PIXI.Matrix |
Transform matrix |
Type | Description |
---|---|
void |
protected validateBatching() → {boolean}
Test geometry for batching process.
Type | Description |
---|---|
boolean |