GRASS GIS 8 Programmer's Manual
8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
named_colr.c
Go to the documentation of this file.
1
#include <grass/gis.h>
2
#include <string.h>
3
#include <stdio.h>
4
5
static
struct
{
6
const
char
*
name
;
7
float
r
,
g
,
b
;
8
} colors[] = {
9
{
"white"
, 1.00, 1.00, 1.00}, {
"black"
, 0.00, 0.00, 0.00},
10
{
"red"
, 1.00, 0.00, 0.00}, {
"green"
, 0.00, 1.00, 0.00},
11
{
"blue"
, 0.00, 0.00, 1.00}, {
"yellow"
, 1.00, 1.00, 0.00},
12
{
"magenta"
, 1.00, 0.00, 1.00}, {
"cyan"
, 0.00, 1.00, 1.00},
13
{
"aqua"
, 0.00, 0.75, 0.75}, {
"grey"
, 0.75, 0.75, 0.75},
14
{
"gray"
, 0.75, 0.75, 0.75}, {
"orange"
, 1.00, 0.50, 0.00},
15
{
"brown"
, 0.75, 0.50, 0.25}, {
"purple"
, 0.50, 0.00, 1.00},
16
{
"violet"
, 0.50, 0.00, 1.00}, {
"indigo"
, 0.00, 0.50, 1.00},
17
{
""
, 0.00, 0.00, 0.00}
/* do not modify this line */
18
};
19
20
int
G_color_values
(
const
char
*
name
,
float
*
r
,
float
*
g
,
float
*
b
)
21
{
22
int
i;
23
24
*
r
= *
g
= *
b
= 0.0;
25
for
(i = 0; colors[i].name[0]; i++)
26
if
(strcmp(
name
, colors[i].
name
) == 0) {
27
*
r
= colors[i].r;
28
*
g
= colors[i].g;
29
*
b
= colors[i].b;
30
return
1;
31
}
32
return
-1;
33
}
34
35
const
char
*
G_color_name
(
int
n)
36
{
37
int
i;
38
39
if
(n >= 0)
40
for
(i = 0; colors[i].name[0]; i++)
41
if
(i == n)
42
return
colors[i].name;
43
return
NULL
;
44
}
NULL
#define NULL
Definition
ccmath.h:32
b
double b
Definition
driver/set_window.c:5
r
double r
Definition
driver/set_window.c:5
G_color_values
int G_color_values(const char *name, float *r, float *g, float *b)
Definition
named_colr.c:20
g
float g
Definition
named_colr.c:7
name
const char * name
Definition
named_colr.c:6
G_color_name
const char * G_color_name(int n)
Definition
named_colr.c:35
gis
named_colr.c
Generated on Sat Jun 21 2025 21:07:27 for GRASS GIS 8 Programmer's Manual by
1.13.2