BRL-CAD
|
Support for storing and manipulating color data. More...
Files | |
file | color.h |
Data Structures | |
struct | bu_color |
Macros | |
#define | RED 0 |
#define | GRN 1 |
#define | BLU 2 |
#define | ALP 3 |
#define | HUE 0 |
#define | SAT 1 |
#define | VAL 2 |
#define | BU_COLOR_NULL ((struct bu_color *) 0) |
#define | BU_COLOR_INIT(_c) |
#define | BU_COLOR_INIT_ZERO {{0, 0, 0, 0}} |
#define | BU_COLOR_CPY(_dest, _src) |
Typedefs | |
typedef struct bu_color | bu_color_t |
Enumerations | |
enum | bu_color_rand_t { BU_COLOR_RANDOM = 0 , BU_COLOR_RANDOM_LIGHTENED } |
Functions | |
int | bu_color_rand (struct bu_color *c, bu_color_rand_t type) |
void | bu_rgb_to_hsv (const unsigned char *rgb, fastf_t *hsv) |
int | bu_hsv_to_rgb (const fastf_t *hsv, unsigned char *rgb) |
int | bu_color_from_rgb_floats (struct bu_color *cp, const fastf_t *rgb) |
int | bu_color_from_rgb_chars (struct bu_color *cp, const unsigned char *rgb) |
int | bu_color_from_str (struct bu_color *cp, const char *str) |
int | bu_str_to_rgb (const char *str, unsigned char *rgb) |
int | bu_color_to_rgb_floats (const struct bu_color *cp, fastf_t *rgb) |
int | bu_color_to_rgb_chars (const struct bu_color *cp, unsigned char *rgb) |
int | bu_color_to_rgb_ints (const struct bu_color *cp, int *r, int *g, int *b) |
Support for storing and manipulating color data.
#define BU_COLOR_INIT | ( | _c | ) |
initializes a bu_color struct without allocating any memory.
#define BU_COLOR_INIT_ZERO {{0, 0, 0, 0}} |
#define BU_COLOR_CPY | ( | _dest, | |
_src | |||
) |
typedef struct bu_color bu_color_t |
enum bu_color_rand_t |
int bu_color_rand | ( | struct bu_color * | c, |
bu_color_rand_t | type | ||
) |
Function to generate random color
Refactoring points: truly random color 3dm-g: src/libgcv/plugins/rhino/rhino_read.cpp "constrained" random BRLCADWrapper:getRandomColor(): src/conv/step/BRLCADWrapper.cpp
void bu_rgb_to_hsv | ( | const unsigned char * | rgb, |
fastf_t * | hsv | ||
) |
Convert between RGB and HSV color models
R, G, and B are in {0, 1, ..., 255},
H is in [0.0, 360.0), and S and V are in [0.0, 1.0],
If S == 0.0, H is achromatic and set to 0.0
These two routines are adapted from: pp. 592-3 of J.D. Foley, A. van Dam, S.K. Feiner, and J.F. Hughes, Computer graphics: principles and practice, 2nd ed., Addison-Wesley, Reading, MA, 1990.
int bu_hsv_to_rgb | ( | const fastf_t * | hsv, |
unsigned char * | rgb | ||
) |
Utility functions to convert between various containers for color handling.
FIXME: inconsistent input/output parameters! TODO: consider stdarg ... to consolidate all the from functions, e.g., // 3 colors bu_color_create(struct bu_color **colors, "red", "0/255/0", "#0000ff", NULL);
// 2 colors from existing data struct bu_color *colors = NULL; bu_color_create(&colors, "%d/%d/%d", rgb[0], rgb[1], rgb[2], "hsv(%lf,0.5,0.95)", hsv, NULL); bu_color_destroy(colors);
int bu_color_from_rgb_chars | ( | struct bu_color * | cp, |
const unsigned char * | rgb | ||
) |
int bu_color_from_str | ( | struct bu_color * | cp, |
const char * | str | ||
) |
int bu_str_to_rgb | ( | const char * | str, |
unsigned char * | rgb | ||
) |
int bu_color_to_rgb_chars | ( | const struct bu_color * | cp, |
unsigned char * | rgb | ||
) |
int bu_color_to_rgb_ints | ( | const struct bu_color * | cp, |
int * | r, | ||
int * | g, | ||
int * | b | ||
) |