hwbTorgb static method

List<int> hwbTorgb(
  1. num hue,
  2. num white,
  3. num black
)

Implementation

static List<int> hwbTorgb(num hue, num white, num black) {
  white /= 100;
  black /= 100;
  if (white + black >= 1) {
    int gray = (white / (white + black)).round();
    return [gray, gray, gray];
  }
  List<double> rgb1 = hslToRgb1Scale(hue, 100, 50);
  for (int i = 0; i < 3; i++) {
    rgb1[i] *= (1 - white - black);
    rgb1[i] += white;
  }
  return [
    (rgb1[0] * 255).round(),
    (rgb1[1] * 255).round(),
    (rgb1[2] * 255).round()
  ];
}