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

bounds PIXI.Bounds

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.

_bounds PIXI.Bounds protected

Cached bounds.

batchDirty number protected

Batches need to regenerated if the geometry is updated.

batches Array<PIXI.graphicsUtils.BatchPart> protected

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

boundsDirty number protected

The bounds dirty flag.

cacheDirty number protected

Used to check if the cache is dirty.

clearDirty number protected

Used to detect if we cleared the graphicsData.

Default Value:
  • 0

colors Array protected

The collection of colors

dirty number protected

Used to detect if the graphics object has changed.

drawCalls Array protected

List of current draw calls drived from the batches.

graphicsData Array<PIXI.GraphicsData> protected

The collection of drawn shapes.

indices Array protected

The indices of the vertices

points Array protected

An array of points to draw, 2 numbers per point

shapeIndex number protected

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

textureIds Array protected

Reference to the texture IDs.

uvs Array protected

The UVs collection

Methods

_compareStyles (styleA, styleB) boolean

Affinity check

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

adjustUvs (uvs, texture, start, size) void

Modify uvs array according to position of texture region Does not work with rotated or trimmed textures

Name Type Description
uvs Array

array

texture PIXI.Texture

region

start number

starting index for uvs

size number

how many points to adjust

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

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.

Destroys the GraphicsGeometry object.

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

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.

invalidate () void

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

updateBatches (aloow32Indices) void

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
aloow32Indices boolean <optional>

Allow using 32-bit indices for preventings artefacts when more that 65535 vertices

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

Add colors.

Name Type Description
colors Array

List of colors to add to

color number

Color to add

alpha number

Alpha to use

size number

Number of colors to add

addTextureIds (textureIds, id, size) void protected

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

Name Type Description
textureIds Array
id number
size number

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

Generates the UVs for a shape.

Name Type Attributes Description
verts Array

Vertices

uvs Array

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.

buildDrawCalls () void protected

Converts intermediate batches data to drawCalls.

calculateBounds () void protected

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

isBatchable () boolean protected

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

Packs attributes to single buffer.

packBatches () void protected

Offset the indices so that it works with the batcher.

processFill (data) void protected

Process fill part of Graphics.

Name Type Description
data PIXI.GraphicsData

processHoles (holes) void protected

Process the holes data.

Name Type Description
holes Array<PIXI.GraphicsData>

Holes to render

processLine (data) void protected

Process line part of Graphics.

Name Type Description
data PIXI.GraphicsData

transformPoints (points, matrix) void protected

Transform points using matrix.

Name Type Description
points Array

Points to transform

matrix PIXI.Matrix

Transform matrix

validateBatching () boolean protected

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

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

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 <optional>

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 Number <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.

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

returns a clone of the geometry

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

dispose () void inherited

disposes WebGL resources that are connected to this geometry

returns the requested attribute

Name Type Description
id String

the name of the attribute required

Returns:
Type Description
PIXI.Attribute the attribute requested.

returns the requested buffer

Name Type Description
id String

the name of the buffer required

Returns:
Type Description
PIXI.Buffer the buffer requested.

returns the index buffer

Returns:
Type Description
PIXI.Buffer the index buffer.

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.