GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
tran_colr.c File Reference
#include <string.h>
#include <grass/colors.h>
#include <grass/display.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/raster.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
 
int D_translate_color (const char *str)
 color name to number
 
int D_use_color (int color)
 draw with a color from D_parse_color
 
int D_color_number_to_RGB (int color, int *r, int *g, int *b)
 get RGB values from color number
 
void D_RGB_color (int red, int grn, int blu)
 

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.

Parameters
colorThe color number provided by D_parse_color to convert into 0-255 RGB values.
rPointer to an integer where the red component will be stored.
gPointer to an integer where the green component will be stored.
bPointer to an integer where the blue component will be stored.
Returns
Returns 1 if color can be used to draw (is good and isn't 'none'), 0 otherwise.

Definition at line 179 of file tran_colr.c.

References color_rgb::b, b, color_rgb::g, g, G_num_standard_colors(), G_standard_color_rgb(), 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.

Parameters
strColor name or color code, as a string
none_acceptable
Returns
int Returns a color number usable by D_use_color.

Definition at line 103 of file tran_colr.c.

References _, and G_fatal_error().

Referenced by D_erase(), and D_translate_color().

◆ D_RGB_color()

void D_RGB_color ( int  red,
int  grn,
int  blu 
)

Definition at line 213 of file tran_colr.c.

References COM_Color_RGB().

Referenced by D_color_of_type(), and D_use_color().

◆ 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.

Parameters
strColor name as an ASCII string
Returns
int

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.

Parameters
color
Returns
int

Definition at line 141 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().