[GRASS5] Suggested color function names
Hamish
hamish_nospam at yahoo.com
Mon Apr 24 07:24:00 EDT 2006
> BTW, I suggest removing the "set" field from the structure. Without
> that field, the structure fits into 32 bits, and I suspect that most
> functions would ignore that field anyhow.
>
> In specific cases where you actually need a "set" field, you can use
> a separate type, e.g.:
>
> struct XRGBA_Color
> {
> int set;
> RGBA_Color color;
> }
I could live without set,unset, but how to do you pass a color of "none"
with just,
typedef struct
{
unsigned char r, g, b, a; /* red, green, blue, and alpha */
} RGBA_Color ;
????
currently I have:
ret = G_str_to_color(fill_color_str, &fill_color->r, &fill_color->g, &fill_color->b);
if (ret == 1) {
fill_color->a = 1; /* alpha channel is not used by the display drivers */
fill_color->set = 1;
}
else if (ret == 2)
fill_color->set = -1; /* "none" */
else {
G_warning(_("[%s]: No such color"), fill_color_str);
return(-1);
}
Note 1) G_str_to_color() returns R,G,B as int, causing a warning;
Cedric's proposed G_str_to_RGBA_color() would fix that.
Note 2) "->set=RGBA_COLOR_SET;" if we add those (I think we should)
> and I suspect that most functions would ignore that field anyhow.
That is just a matter of discipline. Currently we have 100% compliance :)
If we do keep .set, the lib functions should definitely use it, even if
modules' caller fns ignore it.
Hamish
More information about the grass-dev
mailing list