ColorGradient constructor

ColorGradient(
  1. List<ColorStop> stops, {
  2. int resolution = 64,
})

Builds a gradient from stops, baked into a resolution-entry table.

Stops need not be sorted. An empty list is treated as opaque white. Each table entry holds four floats (r, g, b, a). resolution must be >= 2.

Implementation

ColorGradient(List<ColorStop> stops, {this.resolution = 64})
  : assert(resolution >= 2),
    stops = List<ColorStop>.unmodifiable(
      [...stops]..sort((a, b) => a.t.compareTo(b.t)),
    ),
    _lut = Float32List(resolution * 4) {
  _bake(this.stops);
}