GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r73103
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.

Functions

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)
 

Function Documentation

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.

Parameters
color_number
red
green
blue
Returns
int

Definition at line 180 of file tran_colr.c.

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

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.

Parameters
name_or_code
none_acceptable
Returns
int

Definition at line 101 of file tran_colr.c.

References _, and G_fatal_error().

Referenced by D_erase(), and D_translate_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(), and D_use_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.

Parameters
name
Returns
int

Definition at line 126 of file tran_colr.c.

References D_parse_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.

Parameters
color
Returns
int

Definition at line 143 of file tran_colr.c.

References color_rgb::b, COM_Standard_color(), D_RGB_color(), color_rgb::g, G_num_standard_colors(), and color_rgb::r.

Referenced by D_erase().