Gradient.linear constructor

Gradient.linear(
  1. Offset from,
  2. Offset to,
  3. List<Color> colors,
  4. [List<double> colorStops,
  5. TileMode tileMode = TileMode.clamp,
  6. Float64List matrix4]
)

Creates a linear gradient from from to to.

If colorStops is provided, colorStops[i] is a number from 0.0 to 1.0 that specifies where color[i] begins in the gradient. If colorStops is not provided, then only two stops, at 0.0 and 1.0, are implied (and color must therefore only have two entries).

The behavior before from and after to is described by the tileMode argument. For details, see the TileMode enum.

If from, to, colors, or tileMode are null, or if colors or colorStops contain null values, this constructor will throw a NoSuchMethodError.

If matrix4 is provided, the gradient fill will be transformed by the specified 4x4 matrix relative to the local coordinate system. matrix4 must be a column-major matrix packed into a list of 16 values.

Implementation

Gradient.linear(
  Offset from,
  Offset to,
  List<Color> colors, [
  List<double> colorStops,
  TileMode tileMode = TileMode.clamp,
  Float64List matrix4,
]) : assert(_offsetIsValid(from)),
     assert(_offsetIsValid(to)),
     assert(colors != null),
     assert(tileMode != null),
     assert(matrix4 == null || _matrix4IsValid(matrix4)),
     super._() {
  _validateColorStops(colors, colorStops);
  final Float32List endPointsBuffer = _encodeTwoPoints(from, to);
  final Int32List colorsBuffer = _encodeColorList(colors);
  final Float32List colorStopsBuffer = colorStops == null ? null : Float32List.fromList(colorStops);
  _constructor();
  _initLinear(endPointsBuffer, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
}