drawLines method

void drawLines(
  1. List<double> vertices, {
  2. ColorList? colors,
})

Draws a series of connected line segments (a line strip).

The vertices list should contain pairs of (x, y) coordinates. For n points, n-1 line segments will be drawn. Requires at least 2 points (4 values in vertices).

  • vertices: A list of [x1, y1, x2, y2, ..., xn, yn] coordinates.
  • colors: An optional list of Color objects. If provided, the first color colors[0] is applied to all vertices.

Implementation

void drawLines(List<double> vertices, {ColorList? colors}) {
  _prepareRenderState(_PrimitiveType.lineStrip, texture: Texture.white);
  assert(vertices.length >= 4);

  for (var i = 0; i < vertices.length; i += 2) {
    var x1 = vertices[i];
    var y1 = vertices[i + 1];
    _transfromAndAddVertices(x1, y1, 0.0, 0.0, getColorFromList(colors, i ~/ 2, _encodedColor));
  }
}