saturation static method

List<double> saturation(
  1. double value
)

Implementation

static List<double> saturation(double value) {
  if (value == 0) {
    return [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
  }
  double x = 1 + (value > 0 ? 3 * value : value);
  double xInverted = 1 - x;
  const double lumR = 0.3086;
  const double lumG = 0.6094;
  const double lumB = 0.082;

  return [
    lumR * xInverted + x,
    lumG * xInverted,
    lumB * xInverted,
    0,
    0,
    lumR * xInverted,
    lumG * xInverted + x,
    lumB * xInverted,
    0,
    0,
    lumR * xInverted,
    lumG * xInverted,
    lumB * xInverted + x,
    0,
    0,
    0,
    0,
    0,
    1,
    0
  ];
}