grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

tran_colr.c File Reference
#include <string.h>
#include <grass/display.h>
#include <grass/colors.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "driver.h"
Include dependency graph for tran_colr.c:

Go to the source code of this file.


static int translate_or_add_color (const char *str)
 color name and suggested number to actual number More...
int D_parse_color (const char *str, int none_acceptable)
 color option text to usable color number More...
int D_translate_color (const char *str)
 color name to number More...
int D_use_color (int color)
 draw with a color from D_parse_color More...
int D_color_number_to_RGB (int color, int *r, int *g, int *b)
 get RGB values from color number More...
void D_RGB_color (int red, int grn, int blu)


static struct color_rgbcolors
static int ncolors
static int nalloc

Function Documentation

◆ D_color_number_to_RGB()

int D_color_number_to_RGB ( int  color,
int *  r,
int *  g,
int *  b 

get RGB values from color number

Translates the color number provided by D_parse_color into 0-255 RGB values.

Returns 1 if color can be used to draw (is good and isn't 'none'), 0 otherwise.


Definition at line 180 of file tran_colr.c.

References color_rgb::b, b, c, colors, color_rgb::g, g, G_num_standard_colors(), G_standard_color_rgb(), ncolors, color_rgb::r, and r.

◆ D_parse_color()

int D_parse_color ( const char *  str,
int  none_acceptable 

color option text to usable color number

Converts or looks up the color provided in the string. Returns a color number usable by D_use_color. If the color does not exist exits with a fatal error and message. If the color is none and none_acceptable is not true exits with a fatal error and message.


Definition at line 101 of file tran_colr.c.

References _, G_fatal_error(), and translate_or_add_color().

Referenced by D_erase(), and D_translate_color().

◆ D_RGB_color()

void D_RGB_color ( int  red,
int  grn,
int  blu 

Definition at line 214 of file tran_colr.c.

References COM_Color_RGB().

Referenced by D_color_of_type(), D_use_color(), and symbol().

◆ D_translate_color()

int D_translate_color ( const char *  str)

color name to number

Takes a color name in ascii and returns the color number for that color. Returns 0 if color is not known. The color number returned is for lines and text, not raster graphics.


Definition at line 126 of file tran_colr.c.

References D_parse_color().

◆ D_use_color()

int D_use_color ( int  color)

draw with a color from D_parse_color

Calls R_color or R_standard_color to use the color provided by D_parse_color. Returns 1 if color can be used to draw (is good and isn't none), 0 otherwise.


Definition at line 143 of file tran_colr.c.

References c, colors, COM_Standard_color(), D_RGB_color(), G_num_standard_colors(), and ncolors.

Referenced by D_erase().

◆ translate_or_add_color()

static int translate_or_add_color ( const char *  str)

color name and suggested number to actual number

Takes a color name or red:green:blue code in ascii and a suggested color index. If the color is a standard preallocated color it returns the color number for that color. Otherwise (if the color is not standard) it sets the color of the supplied index to the specified color. Returns -1 if color is not known and 0 if the color is none.


Definition at line 32 of file tran_colr.c.

References color_rgb::b, b, colors, color_rgb::g, g, G_chop(), G_num_standard_color_names(), G_num_standard_colors(), G_standard_color_name(), G_standard_color_rgb(), G_str_to_color(), G_strcasecmp(), G_tolcase(), MAX_COLOR_LEN, nalloc, name, ncolors, color_rgb::r, and r.

Referenced by D_parse_color().

Variable Documentation

◆ colors

struct color_rgb* colors

Definition at line 13 of file tran_colr.c.

Referenced by D_c_color(), D_color(), D_color_number_to_RGB(), D_color_of_type(), D_d_color(), D_draw_c_raster(), D_draw_d_raster(), D_draw_f_raster(), D_draw_raster(), D_f_color(), D_use_color(), draw_cell(), forced_write_old_colors(), Gp_load_sites_thematic(), gsd_ortho_wall(), gsd_put_legend(), Gv_load_vect_thematic(), Gvl_load_colors_data(), gvl_slices_calc(), IL_output_2d(), IL_resample_output_2d(), load_rules_file(), load_rules_name(), organize_fp_lookup(), organize_lookup(), Rast3d_read_colors(), Rast3d_write_colors(), Rast__color_reset(), Rast__lookup_colors(), Rast__organize_colors(), Rast__read_colors(), Rast__write_colors(), Rast_add_c_color_rule(), Rast_add_color_rule(), Rast_add_d_color_rule(), Rast_add_f_color_rule(), Rast_add_modular_c_color_rule(), Rast_add_modular_color_rule(), Rast_add_modular_d_color_rule(), Rast_add_modular_f_color_rule(), Rast_colors_count(), Rast_free_colors(), Rast_get_c_color(), Rast_get_c_color_range(), Rast_get_color(), Rast_get_d_color(), Rast_get_d_color_range(), Rast_get_default_color(), Rast_get_f_color(), Rast_get_fp_color_rule(), Rast_get_null_value_color(), Rast_get_row_colors(), Rast_init_colors(), Rast_invert_colors(), Rast_load_colors(), Rast_load_fp_colors(), Rast_lookup_c_colors(), Rast_lookup_colors(), Rast_lookup_d_colors(), Rast_lookup_f_colors(), Rast_make_aspect_colors(), Rast_make_aspect_fp_colors(), Rast_make_bgyr_colors(), Rast_make_bgyr_fp_colors(), Rast_make_byg_colors(), Rast_make_byg_fp_colors(), Rast_make_byr_colors(), Rast_make_byr_fp_colors(), Rast_make_colors(), Rast_make_fp_colors(), Rast_make_grey_scale_colors(), Rast_make_grey_scale_fp_colors(), Rast_make_gyr_colors(), Rast_make_gyr_fp_colors(), Rast_make_histogram_eq_colors(), Rast_make_histogram_log_colors(), Rast_make_rainbow_colors(), Rast_make_rainbow_fp_colors(), Rast_make_ramp_colors(), Rast_make_ramp_fp_colors(), Rast_make_random_colors(), Rast_make_ryg_colors(), Rast_make_ryg_fp_colors(), Rast_make_wave_colors(), Rast_make_wave_fp_colors(), Rast_map_to_img_str(), Rast_mark_colors_as_fp(), Rast_print_colors(), Rast_read_color_rules(), Rast_read_colors(), Rast_set_c_color(), Rast_set_c_color_range(), Rast_set_d_color(), Rast_set_d_color_range(), Rast_set_default_color(), Rast_set_null_value_color(), Rast_shift_c_colors(), Rast_shift_d_colors(), Rast_write_colors(), read_colors(), read_new_colors(), read_old_colors(), slice_calc(), translate_or_add_color(), Vect_read_colors(), Vect_write_colors(), write_new_colors(), and write_old_colors().

◆ nalloc

int nalloc

◆ ncolors

int ncolors

Definition at line 14 of file tran_colr.c.

Referenced by D_color_number_to_RGB(), D_use_color(), and translate_or_add_color().