linearRgbAtY method

ColorTriplet linearRgbAtY(
  1. double y
)

Returns linear RGB for the given row.

Coordinates are given in percent and must be between 0 and 1. Throws ArgumentError if the coordinates are out of range. ColorTriplet by default is in linear RGB color space. Convert to RGB before using the color. See ColorTripletExtensions.toRgb.

Implementation

ColorTriplet linearRgbAtY(double y) {
  if (y < 0.0 || y > 1.0) {
    throw ArgumentError('Coordinates must be between [0, 1].');
  }

  var i = 0;
  var sum = ColorTriplet(0, 0, 0);
  for (final horizontalComponents in components) {
    sum += horizontalComponents[0] * cos(pi * i++ * y);
  }
  return sum;
}