gray method

AnsiPen gray({
  1. num? level,
  2. bool bg = false,
})

Set foreground to ANSI gray when called with no args (pen.gray), or set to a xterm256 grayscale value when called with level: (compatible with ansicolor's AnsiPen.gray() signature).

Implementation

AnsiPen gray({num? level, bool bg = false}) {
  if (level != null) {
    final int code = 232 + (level.clamp(0.0, 1.0) * 23).round();
    styleStack.add(
        bg ? QuectoColors.bgAnsi256(code) : QuectoColors.ansi256(code));
  } else if (bg) {
    styleStack.add(QuectoColors.bgGray);
  } else {
    styleStack.add(QuectoColors.gray);
  }
  return this;
}