/* rgb24.pk - RGB24 encoding of colors.  */

/* Copyright (C) 2020, 2021, 2022, 2023, 2024 Jose E. Marchesi.  */

/* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

load color;

/* This pickle defines utilities to work with RGB 24 encoding of
   colors.  It also includes a table associating standard poke colors
   to their corresponding RGB24 encodings.  */

/* Each color beam is encoded by an unsigned 8-bit integer.  */

type RGB24_Color_Beam = uint<8>;

/* A RGB24 color is the composition of red, green and blue beams.  */

type RGB24_Color = RGB24_Color_Beam[3];

var RGB24_RED = 0,
    RGB24_GREEN = 1,
    RGB24_BLUE = 2;

/* RGB24 colors for the standard colors.  */

var rgb24_color =
  [[255UB,255UB,255UB], /* white */
   [0UB,0UB,0UB],       /* black */
   [190UB,190UB,190UB], /* grey */
   [255UB,0UB,0UB],     /* red */
   [255UB,99UB,71UB],   /* tomato */
   [0UB,255UB,0UB],     /* green */
   [0UB,0UB,255UB],     /* blue */
  ];

/* Sanity check.  */

assert (rgb24_color'length == color_num_colors);
