Class: GraphicsGeometry

PIXI.GraphicsGeometry

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.

Extends

Members

PIXI.GraphicsGeometry.BATCHABLE_SIZE number static

The maximum number of points to consider an object "batchable", able to be batched by the renderer's batch system. \

Default Value:
  • 100

batchDirty number

Batches need to regenerated if the geometry is updated.

Default Value:
  • -1

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

bounds PIXI.Bounds readonly

Get the current bounds of the graphic geometry.

boundsPadding number

Padding to add to the bounds.

Default Value:
  • 0

closePointEps number

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

Default Value:
  • 0.0001

colors number[]

The collection of colors

drawCalls Array<PIXI.BatchDrawCall>

List of current draw calls drived from the batches.

graphicsData Array<PIXI.GraphicsData>

The collection of drawn shapes.

indices number[]

The indices of the vertices

points number[]

An array of points to draw, 2 numbers per point

textureIds number[]

Reference to the texture IDs.

uvs number[]

The UVs collection

_bounds PIXI.Bounds protected

Cached bounds.

boundsDirty number protected

The bounds dirty flag.

Default Value:
  • -1

cacheDirty number protected

Used to check if the cache is dirty.

Default Value:
  • -1

clearDirty number protected

Used to detect if we cleared the graphicsData.

Default Value:
  • 0

dirty number protected

Used to detect if the graphics object has changed.

Default Value:
  • 0

shapeIndex number protected

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

Default Value:
  • 0

Methods

clear () PIXI.GraphicsGeometry

GraphicsGeometry.ts:191

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 (point) Boolean

GraphicsGeometry.ts:291

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

Name Type Description
point PIXI.IPointData

Point to check if it's contained.

Returns:
Type Description
Boolean true if the point is contained within geometry.

destroy () void overrides

GraphicsGeometry.ts:258

Destroys the GraphicsGeometry object.

drawHole (shape, matrix) PIXI.GraphicsGeometry

GraphicsGeometry.ts:231

Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.

Name Type Description
shape PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle

The shape object to draw.

matrix PIXI.Matrix

Transform applied to the points of the shape.

Returns:
Type Description
PIXI.GraphicsGeometry Returns geometry for chaining.

drawShape (shape, fillStyle, lineStyle, matrix) PIXI.GraphicsGeometry

GraphicsGeometry.ts:208

Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.

Name Type Description
shape PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.Rectangle | PIXI.RoundedRectangle

The shape object to draw.

fillStyle PIXI.FillStyle

Defines style of the fill.

lineStyle PIXI.LineStyle

Defines style of the lines.

matrix PIXI.Matrix

Transform applied to the points of the shape.

Returns:
Type Description
PIXI.GraphicsGeometry Returns geometry for chaining.

updateBatches (allow32Indices) void

GraphicsGeometry.ts:351

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

Name Type Attributes Description
allow32Indices boolean <optional>

Allow using 32-bit indices for preventing artifacts when more that 65535 vertices

_compareStyles (styleA, styleB) boolean protected

GraphicsGeometry.ts:489

Affinity check

Name Type Description
styleA PIXI.FillStyle | PIXI.LineStyle
styleB PIXI.FillStyle | PIXI.LineStyle
Returns:
Type Description
boolean

addColors (colors, color, alpha, size, offset) void protected

GraphicsGeometry.ts:930

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

addTextureIds (textureIds, id, size, offset) void protected

GraphicsGeometry.ts:960

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

Name Type Default Description
textureIds Array<number>
id number
size number
offset number 0

addUvs (verts, uvs, texture, start, size, matrix) void protected

GraphicsGeometry.ts:983

Generates the UVs for a shape.

Name Type Attributes 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 <optional>

Optional transform for all points.

adjustUvs (uvs, texture, start, size) void protected

GraphicsGeometry.ts:1033

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

buildDrawCalls () void protected

GraphicsGeometry.ts:597

Converts intermediate batches data to drawCalls.

calculateBounds () void protected

GraphicsGeometry.ts:817

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

invalidate () void protected

GraphicsGeometry.ts:155

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

isBatchable () boolean protected

GraphicsGeometry.ts:570

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 () void protected

GraphicsGeometry.ts:721

Packs attributes to single buffer.

packBatches () void protected

GraphicsGeometry.ts:545

Offset the indices so that it works with the batcher.

processFill (data) void protected

GraphicsGeometry.ts:757

Process fill part of Graphics.

Name Type Description
data PIXI.GraphicsData

processHoles (holes) void protected

GraphicsGeometry.ts:795

Process the holes data.

Name Type Description
holes Array<PIXI.GraphicsData>

Holes to render

processLine (data) void protected

GraphicsGeometry.ts:779

Process line part of Graphics.

Name Type Description
data PIXI.GraphicsData

transformPoints (points, matrix) void protected

GraphicsGeometry.ts:911

Transform points using matrix.

Name Type Description
points Array<number>

Points to transform

matrix PIXI.Matrix

Transform matrix

validateBatching () boolean protected

GraphicsGeometry.ts:520

Test geometry for batching process.

Returns:
Type Description
boolean

Inherited Properties

From class PIXI.BatchGeometry

_buffer PIXI.Buffer protected inherited

Buffer used for position, color, texture IDs

_indexBuffer PIXI.Buffer protected inherited

Index buffer data

From class PIXI.Geometry

instanceCount number inherited

Number of instances in this geometry, pass it to GeometrySystem.draw()

Default Value:
  • 1

refCount number inherited

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

Default Value:
  • 0

glVertexArrayObjects object protected inherited

A map of renderer IDs to webgl VAOs

Inherited Methods

From class PIXI.Geometry

addAttribute (id, buffer, size, normalized, type, stride, start, instance) PIXI.Geometry inherited

Geometry.ts:95

Adds an attribute to the geometry Note: stride and start should be undefined if you dont know them, not 0!

Name Type Attributes Default Description
id String

the name of the attribute (matching up to a shader)

buffer PIXI.Buffer | number<Array>

the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it.

size Number <optional>
0

the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2

normalized Boolean <optional>
false

should the data be normalized.

type PIXI.TYPES <optional>
PIXI.TYPES.FLOAT

what type of number is the attribute. Check {PIXI.TYPES} to see the ones available

stride Number <optional>

How far apart (in floats) the start of each value is. (used for interleaving data)

start Number <optional>

How far into the array to start reading values (used for interleaving data)

instance boolean <optional>
false

Instancing flag

Returns:
Type Description
PIXI.Geometry returns self, useful for chaining.

addIndex (buffer) PIXI.Geometry inherited

Geometry.ts:181

Adds an index buffer to the geometry The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer.

Name Type Attributes Description
buffer PIXI.Buffer | number<Array> <optional>

the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it.

Returns:
Type Description
PIXI.Geometry returns self, useful for chaining.

clone () PIXI.Geometry inherited

Geometry.ts:307

returns a clone of the geometry

Returns:
Type Description
PIXI.Geometry a new clone of this geometry

dispose () void inherited

Geometry.ts:287

disposes WebGL resources that are connected to this geometry

getAttribute (id) PIXI.Attribute inherited

Geometry.ts:159

returns the requested attribute

Name Type Description
id String

the name of the attribute required

Returns:
Type Description
PIXI.Attribute the attribute requested.

getBuffer (id) PIXI.Buffer inherited

Geometry.ts:170

returns the requested buffer

Name Type Description
id String

the name of the buffer required

Returns:
Type Description
PIXI.Buffer the buffer requested.

getIndex () PIXI.Buffer inherited

Geometry.ts:214

returns the index buffer

Returns:
Type Description
PIXI.Buffer the index buffer.

interleave () PIXI.Geometry inherited

Geometry.ts:224

this function modifies the structure so that all current attributes become interleaved into a single buffer This can be useful if your model remains static as it offers a little performance boost

Returns:
Type Description
PIXI.Geometry returns self, useful for chaining.