linearRgbAtX method

ColorTriplet linearRgbAtX(
  1. double x
)

Returns linear RGB for the given column.

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 linearRgbAtX(double x) {
  if (x < 0.0 || x > 1.0) {
    throw ArgumentError('Coordinates must be between [0, 1].');
  }

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