rgb function

int rgb(
  1. int r,
  2. int g,
  3. int b
)

Returns the color index from 256-color table by rgb levels (r,g,b: 0..5).

6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b.

Implementation

int rgb(int r, int g, int b) {
  assert(r >= 0 && r <= 5, _colorComponentAssert);
  assert(g >= 0 && g <= 5, _colorComponentAssert);
  assert(b >= 0 && b <= 5, _colorComponentAssert);

  return 16 + 36 * r + 6 * g + b;
}