clampRgbChannel function

int clampRgbChannel(
  1. int x
)

Clamps a color component to the byte range required by SGR truecolor.

Implementation

int clampRgbChannel(int x) {
  if (x <= 0) return 0;
  if (x >= 0xff) return 0xff;
  return x;
}