62 int *norm,
int *nval,
int *dflt)
64 char value[80], color[80];
68 *norm = *nval = *dflt = 0;
70 if (sscanf(buf,
"%s %[^\n]", value, color) != 2)
90 if (sscanf(value,
"%lf%c", &x, &c) == 2 && c ==
'%') {
94 *val = min + (max -
min) * (x / 100);
99 if (sscanf(value,
"%lf", val) == 1) {
120 return _(
"syntax error in the color rule");
122 return _(
"syntax error in the color format");
130 return _(
"percentage not in range 0-100");
132 return _(
"invalid value");
134 return _(
"unknown error");
153 DCELL * val,
int *
r,
int *
g,
int *
b,
154 int *norm,
int *nval,
int *dflt)
160 *norm = *nval = *dflt = 0;
163 if (!
G_getl2(buf,
sizeof(buf), fp))
167 G_debug(5,
"color buf = [%s]", buf);
201 struct rule *rule =
NULL;
203 struct rule dflt, null;
204 int set, is_null, is_dflt,
r,
g,
b;
214 dflt.r = dflt.g = dflt.b = dflt.set = 0;
215 null.r = null.g = null.b = null.set = 0;
218 (closure, min, max, &val, &r, &g, &b, &
set, &is_null, &is_dflt)) {
219 struct rule *p =
NULL;
223 rule =
G_realloc(rule, nrules *
sizeof(
struct rule));
245 const struct rule *p = &rule[0];
250 for (n = 1; n < nrules; n++) {
251 struct rule *lo = &rule[n - 1];
252 struct rule *hi = &rule[n];
255 &hi->val, hi->r, hi->g, hi->b, colors);
276 fp = fopen(
path,
"r");
303 return load_rules_file(colors, path, (
DCELL) min, (
DCELL) max);
319 return load_rules_file(colors, path, min, max);
322 static void load_rules_name(
struct Colors *colors,
const char *
name,
329 if (!load_rules_file(colors, path,
min, max))
343 load_rules_name(colors, name, (
DCELL) min, (
DCELL) max);
356 load_rules_name(colors, name, min, max);
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
int Rast_load_fp_colors(struct Colors *colors, const char *path, DCELL min, DCELL max)
Load color floating-point rules from file.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void Rast_set_d_color(DCELL, int, int, int, struct Colors *)
Set a category color (DCELL)
int G_str_to_color(const char *, int *, int *, int *)
Parse color string and set red,green,blue.
void G_free(void *)
Free allocated memory.
void Rast_make_fp_colors(struct Colors *colors, const char *name, DCELL min, DCELL max)
Load color rules from predefined floating-point color table.
int Rast_read_color_rule(void *closure, DCELL min, DCELL max, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt)
Read color rule.
void G_strip(char *)
Removes all leading and trailing white space from string.
int Rast_read_color_rules(struct Colors *colors, DCELL min, DCELL max, read_rule_fn *read_rule, void *closure)
Read color rules from file.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
void Rast_set_default_color(int, int, int, struct Colors *)
Set default color value.
int Rast_load_colors(struct Colors *colors, const char *path, CELL min, CELL max)
Load color rules from file.
void Rast_set_null_value_color(int, int, int, struct Colors *)
Set color for NULL-value.
char * G_chop(char *)
Chop leading and trailing white spaces.
int read_rule_fn(void *, DCELL, DCELL, DCELL *, int *, int *, int *, int *, int *, int *)
const char * G_gisbase(void)
Get full path name of the top level module directory.
int Rast_parse_color_rule(DCELL min, DCELL max, const char *buf, DCELL *val, int *r, int *g, int *b, int *norm, int *nval, int *dflt)
Read color rule.
void Rast_add_d_color_rule(const DCELL *, int, int, int, const DCELL *, int, int, int, struct Colors *)
Adds the floating-point color rule (DCELL version)
const char * Rast_parse_color_rule_error(int code)
Parse color rule.
void Rast_init_colors(struct Colors *)
Initialize color structure.
int G_debug(int, const char *,...) __attribute__((format(printf
void Rast_make_colors(struct Colors *colors, const char *name, CELL min, CELL max)
Load color rules from predefined color table.