Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

memberof

PIXI

Hierarchy

Index

Constructors

constructor

Properties

Protected _bounds

_bounds: Bounds

_buffer

_buffer: Buffer

_indexBuffer

_indexBuffer: Buffer

attributes

attributes: {}

Type declaration

batchDirty

batchDirty: number

batchable

batchable: boolean

batches

batches: BatchPart[]

Protected boundsDirty

boundsDirty: number

boundsPadding

boundsPadding: number

buffers

buffers: Buffer[]

Protected cacheDirty

cacheDirty: number

Protected clearDirty

clearDirty: number

closePointEps

closePointEps: number

colors

colors: number[]

Protected dirty

dirty: number

disposeRunner

disposeRunner: Runner

drawCalls

drawCalls: BatchDrawCall[]

glVertexArrayObjects

glVertexArrayObjects: {}

Type declaration

  • [key: number]: {}
    • [key: string]: WebGLVertexArrayObject

graphicsData

graphicsData: GraphicsData[]

id

id: number

indexBuffer

indexBuffer: Buffer

indices

indices: number[]

indicesUint16

indicesUint16: Uint16Array | Uint32Array

instanceCount

instanceCount: number

instanced

instanced: boolean

points

points: number[]

refCount

refCount: number

Protected shapeIndex

shapeIndex: number

textureIds

textureIds: number[]

uvs

uvs: number[]

uvsFloat32

uvsFloat32: Float32Array

Static BATCHABLE_SIZE

BATCHABLE_SIZE: number

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

memberof

PIXI.GraphicsGeometry

static
member

{number} BATCHABLE_SIZE

default

100

Accessors

bounds

  • Get the current bounds of the graphic geometry.

    member

    {PIXI.Bounds}

    readonly

    Returns Bounds

Methods

Protected _compareStyles

addAttribute

  • addAttribute(id: string, buffer: Uint32Array | Float32Array | number[] | Buffer, size?: number, normalized?: boolean, type?: TYPES, stride?: number, start?: number, instance?: boolean): GraphicsGeometry
  • Adds an attribute to the geometry Note: stride and start should be undefined if you dont know them, not 0!

    Parameters

    • id: string

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

    • buffer: Uint32Array | Float32Array | number[] | Buffer

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

    • Optional size: number
    • Optional normalized: boolean
    • Optional type: TYPES
    • Optional stride: number
    • Optional start: number
    • Optional instance: boolean

    Returns GraphicsGeometry

    returns self, useful for chaining.

Protected addColors

  • addColors(colors: number[], color: number, alpha: number, size: number): void
  • Add colors.

    Parameters

    • colors: number[]

      List of colors to add to

    • color: number

      Color to add

    • alpha: number

      Alpha to use

    • size: number

      Number of colors to add

    Returns void

addIndex

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

    Parameters

    Returns Geometry

    returns self, useful for chaining.

Protected addTextureIds

  • addTextureIds(textureIds: number[], id: number, size: number): void
  • Add texture id that the shader/fragment wants to use.

    Parameters

    • textureIds: number[]
    • id: number
    • size: number

    Returns void

Protected addUvs

  • addUvs(verts: number[], uvs: number[], texture: Texture<Resource>, start: number, size: number, matrix?: Matrix): void
  • Generates the UVs for a shape.

    Parameters

    • verts: number[]

      Vertices

    • uvs: number[]

      UVs

    • texture: Texture<Resource>

      Reference to Texture

    • start: number

      Index buffer start index.

    • size: number

      The size/length for index buffer.

    • Optional matrix: Matrix

    Returns void

Protected adjustUvs

  • adjustUvs(uvs: number[], texture: Texture<Resource>, start: number, size: number): void
  • Modify uvs array according to position of texture region Does not work with rotated or trimmed textures

    Parameters

    • uvs: number[]

      array

    • texture: Texture<Resource>

      region

    • start: number

      starting index for uvs

    • size: number

      how many points to adjust

    Returns void

Protected buildDrawCalls

  • buildDrawCalls(): void
  • Converts intermediate batches data to drawCalls.

    Returns void

Protected calculateBounds

  • calculateBounds(): void
  • Update the local bounds of the object. Expensive to use performance-wise.

    Returns void

clear

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

    Returns GraphicsGeometry

    This GraphicsGeometry object. Good for chaining method calls

clone

  • returns a clone of the geometry

    Returns Geometry

    a new clone of this geometry

containsPoint

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

    Parameters

    • point: IPointData

      Point to check if it's contained.

    Returns boolean

    true if the point is contained within geometry.

destroy

  • destroy(): void
  • Destroys the GraphicsGeometry object.

    Returns void

dispose

  • dispose(): void
  • disposes WebGL resources that are connected to this geometry

    Returns void

drawHole

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

    Parameters

    • shape: IShape_2

      The shape object to draw.

    • Optional matrix: Matrix

      Transform applied to the points of the shape.

    Returns GraphicsGeometry

    Returns geometry for chaining.

drawShape

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

    Parameters

    • shape: IShape_2

      The shape object to draw.

    • Optional fillStyle: FillStyle

      Defines style of the fill.

    • Optional lineStyle: LineStyle

      Defines style of the lines.

    • Optional matrix: Matrix

      Transform applied to the points of the shape.

    Returns GraphicsGeometry

    Returns geometry for chaining.

getAttribute

  • returns the requested attribute

    Parameters

    • id: string

      the name of the attribute required

    Returns Attribute

    the attribute requested.

getBuffer

  • getBuffer(id: string): Buffer
  • returns the requested buffer

    Parameters

    • id: string

      the name of the buffer required

    Returns Buffer

    the buffer requested.

getIndex

  • returns the index buffer

    Returns Buffer

    the index buffer.

getSize

  • getSize(): number
  • Returns number

interleave

  • 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 Geometry

    returns self, useful for chaining.

Protected invalidate

  • invalidate(): void
  • Call if you changed graphicsData manually. Empties all batch buffers.

    Returns void

Protected isBatchable

  • 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 boolean

Protected packAttributes

  • packAttributes(): void
  • Packs attributes to single buffer.

    Returns void

Protected packBatches

  • packBatches(): void
  • Offset the indices so that it works with the batcher.

    Returns void

Protected processFill

  • Process fill part of Graphics.

    Parameters

    Returns void

Protected processHoles

  • Process the holes data.

    Parameters

    Returns void

Protected processLine

  • Process line part of Graphics.

    Parameters

    Returns void

Protected transformPoints

  • transformPoints(points: number[], matrix: Matrix): void
  • Transform points using matrix.

    Parameters

    • points: number[]

      Points to transform

    • matrix: Matrix

      Transform matrix

    Returns void

updateBatches

  • updateBatches(allow32Indices?: boolean): void
  • Generates intermediate batch data. Either gets converted to drawCalls or used to convert to batch objects directly by the Graphics object.

    Parameters

    • Optional allow32Indices: boolean

    Returns void

Protected validateBatching

  • validateBatching(): boolean
  • Test geometry for batching process.

    Returns boolean

Static merge

  • merges an array of geometries into a new single one geometry attribute styles must match for this operation to work

    Parameters

    • geometries: Geometry[]

      array of geometries to merge

    Returns Geometry

    shiny new geometry!

Generated using TypeDoc