Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-02-04 Thread Hamish
Hi, Color change for d.grid -c,-f is now working. http://trac.osgeo.org/grass/changeset/29944 Please review. Hamish Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-02-01 Thread Glynn Clements
Ivan Shmakov wrote: RGBA_Color was recently added (as was RGB support for modules' CLI options) so 1) it could be used to pass RGB arround without having to call the display library and 2) we could handle a color value of 'none' without needing to pass a separate variable or rely on

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-02-01 Thread Glynn Clements
Ivan Shmakov wrote: The former is only an advantage if there's a situation where a module doesn't just call G_fatal_error() when an invalid colour occurs. Given that invalid user input is usually a fatal error, I can't immediately think of a situation where you might get an

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-02-01 Thread Ivan Shmakov
Glynn Clements [EMAIL PROTECTED] writes: [...] The GRASS libraries are fundamentally designed to be used in one-shot modules. Errors are handled by printing a message then exiting. Variables are either initialised at startup from the .data and .bss segments or are initialised upon first

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-02-01 Thread Ivan Shmakov
Hamish [EMAIL PROTECTED] writes: [...] s/RGB_Color/RGBA_Color/ ? no, the idea there was to be a shortcut for those who wanted to use the struct but didn't care about alpha and didn't want to cause confusion in the variable namespace. In those cases the alpha channel is ignored and

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-31 Thread Glynn Clements
Ivan Shmakov wrote: As lib fns, the one G_fatal_error() would need to change to G_warning(). Or is it better to be silent and rely on the module programmer to check the fn's return code? If it's conceivable that the module will continue in the event of an error, the function

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-31 Thread Glynn Clements
Ivan Shmakov wrote: if (color = 0) return 0; BTW, is it a GRASS convention to use 0 to indicate failure? Standard C library functions tend to use -1 for failure, while using non-negative values to indicate success. The SUBMITTING file in the source code says: 8. Exit

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-31 Thread Glynn Clements
Ivan Shmakov wrote: AFAIK, GRASS itself never sets errno. But, IIUC, it doesn't prevent `errno' from being set by the standard library functions it calls? Setting `errno' would make sense should there be a demand to use the standard C means of error reporting

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-31 Thread Glynn Clements
Hamish wrote: Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? Glynn: Yes. E.g.: int D_color_number_to_RGB(int color, int *r, int *g, int *b) { const struct color_rgb *c; if (color = 0) return 0; if

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-31 Thread Ivan Shmakov
Glynn Clements [EMAIL PROTECTED] writes: [...] If it's likely that the module is just going to call G_fatal_error() anyhow, the library function may as well call it itself, thereby providing a infallible interface (i.e. the function never fails; it either succeeds, or the process is no

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Glynn Clements
Hamish wrote: If I pass the colors as a single RGBA_Color struct, I would like to have a parsing lib fn to replace D_parse_color(). It would call G_str_to_color() then fill the RGBA_Color struct, like set_last_color() in d.graph. e.g.: G_str_to_RGBA(char* str, RGBA_Color color);

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Ivan Shmakov
Moritz Lennert [EMAIL PROTECTED] writes: [...] int D_color_number_to_RGB(int color, int r, int g, int b) [...] if (color = 0) return 0; BTW, is it a GRASS convention to use 0 to indicate failure? Standard C library functions tend to use -1 for failure, while using non-negative

Re: [GRASS-dev] lib fn to convert int color number to RGB values? [+ GRASS 7 plans]

2008-01-30 Thread Glynn Clements
Hamish wrote: All of this should really be harmonised; Yes please. I'm just wondering whether it's too late to do it for 6.4. For 6.x I would suggest it is wasted effort to do so, and against the goal of pre-release stabilization. 2 cents My hope is that we release 6.3.0 soon

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Glynn Clements
Ivan Shmakov wrote: Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? Yes. E.g.: int D_color_number_to_RGB(int color, int r, int g, int b) { That looks a lot like C++. Surely it will work with C89? Oops. I meant:

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Ivan Shmakov
Glynn Clements [EMAIL PROTECTED] writes: [...] As lib fns, the one G_fatal_error() would need to change to G_warning(). Or is it better to be silent and rely on the module programmer to check the fn's return code? If it's conceivable that the module will continue in the event of an

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Ivan Shmakov
Glynn Clements [EMAIL PROTECTED] writes: [...] if (color = 0) return 0; BTW, is it a GRASS convention to use 0 to indicate failure? Standard C library functions tend to use -1 for failure, while using non-negative values to indicate success. The GRASS convention is to use a

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-30 Thread Hamish
Hamish wrote: Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? Glynn: Yes. E.g.: int D_color_number_to_RGB(int color, int *r, int *g, int *b) { const struct color_rgb *c; if (color = 0) return 0; if (color =

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-29 Thread Hamish
Hamish wrote: I am looking for a library function to get the R,G,B values (0-255) for an integer color number which was created with D_parse_color(). Glynn: That information isn't available at present. Also, the concept of colour numbers is likely to go away entirely in 7.x. With the

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-29 Thread Glynn Clements
Hamish wrote: Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? G: Yes. E.g.: int D_color_number_to_RGB(int color, int r, int g, int b) { const struct color_rgb *c; if (color = 0) return 0; if (color =

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-29 Thread Hamish
Hamish wrote: If I pass the colors as a single RGBA_Color struct, I would like to have a parsing lib fn to replace D_parse_color(). It would call G_str_to_color() then fill the RGBA_Color struct, like set_last_color() in d.graph. e.g.: G_str_to_RGBA(char* str, RGBA_Color color); already

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-29 Thread Ivan Shmakov
Glynn Clements [EMAIL PROTECTED] writes: [...] Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? Yes. E.g.: int D_color_number_to_RGB(int color, int r, int g, int b) { That looks a lot like C++. Surely it will work with C89?

Re: [GRASS-dev] lib fn to convert int color number to RGB values? [+ GRASS 7 plans]

2008-01-29 Thread Hamish
Hamish wrote: Is a new D_number_to_RGB(int color, unsigned char r,g,b) fn needed in lib/display/tran_colr.c? Glynn: Yes. E.g.: [...] Hamish: Any reason you use int for the r,g,b type? color.h defines {}color_rgb as unsigned char, as does gis.h's {}RGBA_Color. I'd like to avoid

[GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-28 Thread Hamish
Hi, I am looking for a library function to get the R,G,B values (0-255) for an integer color number which was created with D_parse_color(). I don't want to set the color for drawing, just get the RGB component values so I can populate a RGBA_Color struct. Reparsing the original color string isn't

Re: [GRASS-dev] lib fn to convert int color number to RGB values?

2008-01-28 Thread Michael Barton
On Jan 28, 2008, at 8:32 AM, [EMAIL PROTECTED] wrote: Date: Mon, 28 Jan 2008 04:30:21 -0800 (PST) From: Hamish [EMAIL PROTECTED] Subject: [GRASS-dev] lib fn to convert int color number to RGB values? To: grass-dev@lists.osgeo.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain