makeRGBChalk method

Chalk makeRGBChalk(
  1. num nred,
  2. num ngreen,
  3. num nblue, {
  4. bool bg = false,
  5. bool force16M = false,
})

Implementation

Chalk makeRGBChalk(num nred, num ngreen, num nblue,
    {bool bg = false, bool force16M = false}) {
  if (nred <= 1.0 && ngreen <= 1.0 && nblue <= 1.0 && !noZeroToOneScaling) {
    // if all 0 to 1.0 then scale to 0-255
    nred *= 255;
    ngreen *= 255;
    nblue *= 255;
  }
  final red = nred.round();
  final green = ngreen.round();
  final blue = nblue.round();
  String open;
  final close = bg ? _ansiBgClose : _ansiClose;
  if (level == 3 || force16M) {
    if (bg) {
      open = _bgAnsi16m(red, green, blue);
    } else {
      open = _ansi16m(red, green, blue);
    }
  } else {
    if (bg) {
      open = _bgAnsi256(ColorUtils.rgbToAnsi256(red, green, blue));
    } else {
      open = _ansi256(ColorUtils.rgbToAnsi256(red, green, blue));
    }
  }
  return _createStyler(open, close, this);
}