gameforge - v0.1.12
    Preparing search index...

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

    PIXI

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _bounds: Bounds

    Cached bounds.

    _buffer: Buffer

    Buffer used for position, color, texture IDs

    _indexBuffer: Buffer

    Index buffer data

    attributes: { [key: string]: Attribute }
    batchable: boolean
    batchDirty: number

    Batches need to regenerated if the geometry is updated.

    batches: BatchPart[]

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

    boundsDirty: number

    The bounds dirty flag.

    boundsPadding: number

    Padding to add to the bounds.

    buffers: Buffer[]
    cacheDirty: number

    Used to check if the cache is dirty.

    clearDirty: number

    Used to detect if we cleared the graphicsData.

    closePointEps: number

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

    colors: number[]

    The collection of colors

    dirty: number

    Used to detect if the graphics object has changed.

    disposeRunner: Runner
    drawCalls: BatchDrawCall[]

    List of current draw calls drived from the batches.

    glVertexArrayObjects: {
        [key: number]: { [key: string]: WebGLVertexArrayObject };
    }

    A map of renderer IDs to webgl VAOs

    graphicsData: GraphicsData[]

    The collection of drawn shapes.

    id: number
    indexBuffer: Buffer
    indices: number[]

    The indices of the vertices

    indicesUint16: Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
    instanceCount: number

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

    1
    
    instanced: boolean

    Whether the geometry is instanced.

    points: number[]

    An array of points to draw, 2 numbers per point

    refCount: number

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

    shapeIndex: number

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

    textureIds: number[]

    Reference to the texture IDs.

    uvs: number[]

    The UVs collection

    uvsFloat32: Float32Array
    BATCHABLE_SIZE: number

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

    Accessors

    • get bounds(): Bounds

      Get the current bounds of the graphic geometry.

      Since 6.5.0, bounds of the graphics geometry are calculated based on the vertices of generated geometry. Since shapes or strokes with full transparency (alpha: 0) will not generate geometry, they are not considered when calculating bounds for the graphics geometry. See PR [#8343]https://github.com/pixijs/pixijs/pull/8343 and issue [#8623]https://github.com/pixijs/pixijs/pull/8623.

      Returns Bounds

    Methods

    • 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: Float32Array<ArrayBufferLike> | number[] | Buffer | Uint32Array<ArrayBufferLike>

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

      • Optionalsize: number

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

      • Optionalnormalized: boolean

        should the data be normalized.

      • Optionaltype: TYPES

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

      • Optionalstride: number

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

      • Optionalstart: number

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

      • Optionalinstance: boolean

        Instancing flag

      Returns this

      • Returns self, useful for chaining.
    • 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

      • Optionaloffset: number

      Returns void

    • 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

      • Optionalbuffer: number[] | Buffer | IArrayBuffer

        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 Geometry

      • Returns self, useful for chaining.
    • Add texture id that the shader/fragment wants to use.

      Parameters

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

      Returns void

    • Generates the UVs for a shape.

      Parameters

      • verts: number[]

        Vertices

      • uvs: number[]

        UVs

      • texture: Texture

        Reference to Texture

      • start: number

        Index buffer start index.

      • size: number

        The size/length for index buffer.

      • Optionalmatrix: Matrix

        Optional transform for all points.

      Returns void

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

      Parameters

      • uvs: number[]

        array

      • texture: Texture

        region

      • start: number

        starting index for uvs

      • size: number

        how many points to adjust

      Returns void

    • Converts intermediate batches data to drawCalls.

      Returns void

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

      Returns void

    • 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
    • Returns a clone of the geometry.

      Returns Geometry

      • A new clone of this geometry.
    • 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.

    • Destroys the GraphicsGeometry object.

      Returns void

    • Disposes WebGL resources that are connected to this geometry.

      Returns void

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

      Parameters

      • shape: IShape

        The shape object to draw.

      • Optionalmatrix: Matrix

        Transform applied to the points of the shape.

      Returns GraphicsGeometry

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

      Parameters

      • shape: IShape

        The shape object to draw.

      • OptionalfillStyle: FillStyle

        Defines style of the fill.

      • OptionallineStyle: LineStyle

        Defines style of the lines.

      • Optionalmatrix: Matrix

        Transform applied to the points of the shape.

      Returns GraphicsGeometry

      • Returns geometry for chaining.
    • Returns the requested attribute.

      Parameters

      • id: string

        The name of the attribute required

      Returns Attribute

      • The attribute requested.
    • Returns the requested buffer.

      Parameters

      • id: string

        The name of the buffer required.

      Returns Buffer

      • The buffer requested.
    • Returns the index buffer

      Returns Buffer

      • The index buffer.
    • Get the size of the geometries, in vertices.

      Returns number

    • 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.
    • Call if you changed graphicsData manually. Empties all batch buffers.

      Returns void

    • 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

    • Packs attributes to single buffer.

      Returns void

    • Offset the indices so that it works with the batcher.

      Returns void

    • Process fill part of Graphics.

      Parameters

      Returns void

    • Process the holes data.

      Parameters

      Returns void

    • Process line part of Graphics.

      Parameters

      Returns void

    • Transform points using matrix.

      Parameters

      • points: number[]

        Points to transform

      • matrix: Matrix

        Transform matrix

      Returns void

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

      Returns void

    • Test geometry for batching process.

      Returns boolean

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