GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-38f5cf43d1
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

◆ 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
color_number
red
green
blue
Returns
int

Definition at line 177 of file tran_colr.c.

◆ 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
name_or_code
none_acceptable
Returns
int

Definition at line 101 of file tran_colr.c.

Referenced by D_erase(), and D_translate_color().

◆ D_RGB_color()

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

Definition at line 211 of file tran_colr.c.

References COM_Color_RGB().

◆ 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
name
Returns
int

Definition at line 125 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 COM_Standard_color(), and G_num_standard_colors().

Referenced by D_erase().