Vertices class base

A set of vertex data used by Canvas.drawVertices.

Vertex data consists of a series of points in the canvas coordinate space. Based on the VertexMode, these points are interpreted either as independent triangles (VertexMode.triangles), as a sliding window of points forming a chain of triangles each sharing one side with the next (VertexMode.triangleStrip), or as a fan of triangles with a single shared point (VertexMode.triangleFan).

Each point can be associated with a color. Each triangle is painted as a gradient that blends between the three colors at the three points of that triangle. If no colors are specified, transparent black is assumed for all the points.

These colors are then blended with the Paint specified in the call to Canvas.drawVertices. This paint is either a solid color (Paint.color), or a bitmap, specified using a shader (Paint.shader), typically either a gradient (Gradient) or image (ImageFilter). The bitmap uses the same coordinate space as the canvas (in the case of an ImageFilter, this is notably different than the coordinate space of the source image; the source image is tiled according to the filter's configuration, and the image that is sampled when painting the triangles is the infinite one after all the repeating is applied.)

Each point in the Vertices is associated with a specific point on this image. Each triangle is painted by sampling points from this image by interpolating between the three points of the image corresponding to the three points of the triangle.

The Vertices.new constructor configures all this using lists of Offset and Color objects. The Vertices.raw constructor instead uses Float32List, Int32List, and Uint16List objects, which more closely corresponds to the data format used internally and therefore reduces some of the conversion overhead. The raw constructor is useful if the data is coming from another source (e.g. a file) and can therefore be parsed directly into the underlying representation.

Constructors

Vertices(VertexMode mode, List<Offset> positions, {List<Color>? colors, List<Offset>? textureCoordinates, List<int>? indices})
Creates a set of vertex data for use with Canvas.drawVertices.
Vertices.raw(VertexMode mode, Float32List positions, {Int32List? colors, Float32List? textureCoordinates, Uint16List? indices})
Creates a set of vertex data for use with Canvas.drawVertices, using the encoding expected by the Flutter engine.

Properties

debugDisposed bool
Whether this reference to the underlying vertex data is disposed.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Release the resources used by this object. The object is no longer usable after this method is called.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited