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
static BATCHABLE_SIZE = 100
number
batchDirty = -1

Batches need to regenerated if the geometry is updated.

Array<PIXI.graphicsUtils.BatchPart>
batches
PIXI.Bounds
bounds
number
boundsPadding = 0

Padding to add to the bounds.

number
closePointEps = 0.0001

Minimal distance between points that are considered different. Affects line tesselation.

number[]
colors

The collection of colors

Array<PIXI.BatchDrawCall>
drawCalls
Array<PIXI.GraphicsData>
graphicsData
number[]
indices

The indices of the vertices

number[]
points

An array of points to draw, 2 numbers per point

number[]
textureIds

Reference to the texture IDs.

number[]
uvs

The UVs collection

PIXI.Bounds
protected _bounds

Cached bounds.

number
protected boundsDirty = -1

The bounds dirty flag.

number
protected cacheDirty = -1

Used to check if the cache is dirty.

number
protected clearDirty = 0

Used to detect if we cleared the graphicsData.

number
protected dirty = 0

Used to detect if the graphics object has changed.

number
protected shapeIndex = 0

Index of the last batched shape in the stack of calls.

Methods from GraphicsGeometry

PIXI.GraphicsGeometry
clear()
boolean
containsPoint(point: IPointData)
void
destroy()

Destroys the GraphicsGeometry object.

PIXI.GraphicsGeometry
drawHole(shape: PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle, matrix: PIXI.Matrix)
PIXI.GraphicsGeometry
drawShape(shape: PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle, fillStyle: PIXI.FillStyle, lineStyle: PIXI.LineStyle, matrix: PIXI.Matrix)
void
updateBatches()
boolean
protected _compareStyles(styleA: PIXI.FillStyle | PIXI.LineStyle, styleB: PIXI.FillStyle | PIXI.LineStyle)
void
protected addColors(colors: Array<number>, color: number, alpha: number, size: number, offset: number)
void
protected addTextureIds(textureIds: Array<number>, id: number, size: number, offset: number)
void
protected addUvs(verts: Array<number>, uvs: Array<number>, texture: PIXI.Texture, start: number, size: number, matrix: PIXI.Matrix)
void
protected adjustUvs(uvs: Array<number>, texture: PIXI.Texture, start: number, size: number)
void
protected buildDrawCalls()

Converts intermediate batches data to drawCalls.

void
protected calculateBounds()

Update the local bounds of the object. Expensive to use performance-wise.

void
protected invalidate()

Call if you changed graphicsData manually. Empties all batch buffers.

boolean
protected isBatchable()
void
protected packAttributes()

Packs attributes to single buffer.

void
protected packBatches()

Offset the indices so that it works with the batcher.

void
protected processFill(data: PIXI.GraphicsData)
void
protected processHoles(holes: Array<PIXI.GraphicsData>)
void
protected processLine(data: PIXI.GraphicsData)
void
protected transformPoints(points: Array<number>, matrix: PIXI.Matrix)
boolean
protected validateBatching()

Test geometry for batching process.

Properties inherited from BatchGeometry

Properties inherited from Geometry

object
glVertexArrayObjects
number
instanceCount = 1
boolean
instanced

Whether the geometry is instanced.

number
refCount

Count of existing (not destroyed) meshes that reference this geometry.

Methods inherited from Geometry

this
addAttribute(id: string, buffer: PIXI.Buffer | number<Array>, size: number, normalized: boolean, type: PIXI.TYPES, stride: number, start: number, instance: boolean)
PIXI.Geometry
addIndex(buffer: PIXI.Buffer | number<Array>)
PIXI.Geometry
clone()
void
dispose()

Disposes WebGL resources that are connected to this geometry.

PIXI.Attribute
getAttribute(id: string)
PIXI.Buffer
getBuffer(id: string)
PIXI.Buffer
getIndex()
number
getSize()

Get the size of the geometries, in vertices.

PIXI.Geometry
interleave()

Public Properties


BATCHABLE_SIZE GraphicsGeometry.ts:47
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 GraphicsGeometry.ts:91
batchDirty: number = -1

Batches need to regenerated if the geometry is updated.

batches GraphicsGeometry.ts:94
batches: Array<PIXI.graphicsUtils.BatchPart>

Intermediate abstract format sent to batch system. Can be converted to drawCalls or to batchable objects.

bounds GraphicsGeometry.ts:125
bounds: PIXI.Bounds

Get the current bounds of the graphic geometry.

boundsPadding GraphicsGeometry.ts:57
boundsPadding: number = 0

Padding to add to the bounds.

closePointEps GraphicsGeometry.ts:54
closePointEps: number = 0.0001

Minimal distance between points that are considered different. Affects line tesselation.

colors GraphicsGeometry.ts:67
colors: number[]

The collection of colors

drawCalls GraphicsGeometry.ts:85
drawCalls: Array<PIXI.BatchDrawCall>

List of current draw calls drived from the batches.

graphicsData GraphicsGeometry.ts:79
graphicsData: Array<PIXI.GraphicsData>

The collection of drawn shapes.

indices GraphicsGeometry.ts:73
indices: number[]

The indices of the vertices

points GraphicsGeometry.ts:64
points: number[]

An array of points to draw, 2 numbers per point

textureIds GraphicsGeometry.ts:76
textureIds: number[]

Reference to the texture IDs.

uvs GraphicsGeometry.ts:70
uvs: number[]

The UVs collection

Protected Properties


_bounds GraphicsGeometry.ts:113
protected _bounds: PIXI.Bounds

Cached bounds.

boundsDirty GraphicsGeometry.ts:116
protected boundsDirty: number = -1

The bounds dirty flag.

cacheDirty GraphicsGeometry.ts:104
protected cacheDirty: number = -1

Used to check if the cache is dirty.

clearDirty GraphicsGeometry.ts:107
protected clearDirty: number = 0

Used to detect if we cleared the graphicsData.

dirty GraphicsGeometry.ts:101
protected dirty: number = 0

Used to detect if the graphics object has changed.

shapeIndex GraphicsGeometry.ts:110
protected shapeIndex: number = 0

Index of the last batched shape in the stack of calls.

Public Methods


clear GraphicsGeometry.ts:175
clear() → {PIXI.GraphicsGeometry}

Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.

Returns:
Type Description
PIXI.GraphicsGeometry
  • This GraphicsGeometry object. Good for chaining method calls
containsPoint GraphicsGeometry.ts:269
containsPoint(point: IPointData) → {boolean}

Check to see if a point is contained within this geometry.

Parameters:
Name Type Description
point IPointData

Point to check if it's contained.

Returns:
Type Description
boolean

true if the point is contained within geometry.

destroy GraphicsGeometry.ts:239
destroy() → {void}

Destroys the GraphicsGeometry object.

Returns:
Type Description
void
drawHole GraphicsGeometry.ts:213
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.

Parameters:
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.

Returns:
Type Description
PIXI.GraphicsGeometry
  • Returns geometry for chaining.
drawShape GraphicsGeometry.ts:191
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.

Parameters:
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.

Returns:
Type Description
PIXI.GraphicsGeometry
  • Returns geometry for chaining.
updateBatches GraphicsGeometry.ts:328
updateBatches() → {void}

Generates intermediate batch data. Either gets converted to drawCalls or used to convert to batch objects directly by the Graphics object.

Returns:
Type Description
void

Protected Methods


_compareStyles GraphicsGeometry.ts:469
protected _compareStyles(styleA: PIXI.FillStyle | PIXI.LineStyle, styleB: PIXI.FillStyle | PIXI.LineStyle) → {boolean}

Affinity check

Parameters:
Name Type Description
styleA PIXI.FillStyle | PIXI.LineStyle
styleB PIXI.FillStyle | PIXI.LineStyle
Returns:
Type Description
boolean
addColors GraphicsGeometry.ts:797
protected addColors(colors: Array<number>, color: number, alpha: number, size: number, offset: number) → {void}

Add colors.

Parameters:
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
Returns:
Type Description
void
addTextureIds GraphicsGeometry.ts:825
protected addTextureIds(textureIds: Array<number>, id: number, size: number, offset: number) → {void}

Add texture id that the shader/fragment wants to use.

Parameters:
Name Type Default Description
textureIds Array<number>
id number
size number
offset number 0
Returns:
Type Description
void
addUvs GraphicsGeometry.ts:846
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.

Parameters:
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.

Returns:
Type Description
void
adjustUvs GraphicsGeometry.ts:894
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

Parameters:
Name Type Description
uvs Array<number>

array

texture PIXI.Texture

region

start number

starting index for uvs

size number

how many points to adjust

Returns:
Type Description
void
buildDrawCalls GraphicsGeometry.ts:566
protected buildDrawCalls() → {void}

Converts intermediate batches data to drawCalls.

Returns:
Type Description
void
calculateBounds GraphicsGeometry.ts:770
protected calculateBounds() → {void}

Update the local bounds of the object. Expensive to use performance-wise.

Returns:
Type Description
void
invalidate GraphicsGeometry.ts:142
protected invalidate() → {void}

Call if you changed graphicsData manually. Empties all batch buffers.

Returns:
Type Description
void
isBatchable GraphicsGeometry.ts:541
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.

Returns:
Type Description
boolean
packAttributes GraphicsGeometry.ts:686
protected packAttributes() → {void}

Packs attributes to single buffer.

Returns:
Type Description
void
packBatches GraphicsGeometry.ts:520
protected packBatches() → {void}

Offset the indices so that it works with the batcher.

Returns:
Type Description
void
processFill GraphicsGeometry.ts:718
protected processFill(data: PIXI.GraphicsData) → {void}

Process fill part of Graphics.

Parameters:
Name Type Description
data PIXI.GraphicsData
Returns:
Type Description
void
processHoles GraphicsGeometry.ts:750
protected processHoles(holes: Array<PIXI.GraphicsData>) → {void}

Process the holes data.

Parameters:
Name Type Description
holes Array<PIXI.GraphicsData>
Returns:
Type Description
void
processLine GraphicsGeometry.ts:736
protected processLine(data: PIXI.GraphicsData) → {void}

Process line part of Graphics.

Parameters:
Name Type Description
data PIXI.GraphicsData
Returns:
Type Description
void
transformPoints GraphicsGeometry.ts:780
protected transformPoints(points: Array<number>, matrix: PIXI.Matrix) → {void}

Transform points using matrix.

Parameters:
Name Type Description
points Array<number>

Points to transform

matrix PIXI.Matrix

Transform matrix

Returns:
Type Description
void
validateBatching GraphicsGeometry.ts:499
protected validateBatching() → {boolean}

Test geometry for batching process.

Returns:
Type Description
boolean

Powered by webdoc!