Freeciv-3.3
Loading...
Searching...
No Matches
rgbcolor.h
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2010 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12****************************************************************************/
13#ifndef FC__RGBCOLOR_H
14#define FC__RGBCOLOR_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "shared.h"
22
23struct section_file;
24
25/* Used for the color system in the client and the definition of the terrain
26 * colors used in the overview/map images. The values are read from the
27 * rulesets. */
28struct color;
29
30/* An RGBcolor contains the R,G,B bitvalues for a color. The color itself
31 * holds the color structure for this color but may be NULL (it's allocated
32 * on demand at runtime). */
33struct rgbcolor {
34 int r, g, b;
35 struct color *color;
36};
37
38/* get 'struct color_list' and related functions: */
39#define SPECLIST_TAG rgbcolor
40#define SPECLIST_TYPE struct rgbcolor
41#include "speclist.h"
42
43#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor) \
44 TYPED_LIST_ITERATE(struct rgbcolor, rgbcolorlist, prgbcolor)
45#define rgbcolor_list_iterate_end LIST_ITERATE_END
46
47/* Check the RGB color values. If a value is not in the interval [0, 255]
48 * clip it to the interval boundaries. */
49#define CHECK_RGBCOLOR(_str, _c, _colorname) \
50 { \
51 int _color_save = _c; \
52 \
53 _c = CLIP(0, _c, 255); \
54 if (_c != _color_save) { \
55 log_error("Invalid value for '%s' in color definition '%s' (%d). " \
56 "Setting it to '%d'.", _colorname, _str, _color_save, _c); \
57 } \
58 }
59#define rgbcolor_check(_str, _r, _g, _b) \
60 { \
61 CHECK_RGBCOLOR(_str, _r, "red"); \
62 CHECK_RGBCOLOR(_str, _g, "green"); \
63 CHECK_RGBCOLOR(_str, _b, "blue"); \
64 }
65
66struct rgbcolor *rgbcolor_new(int r, int g, int b);
67struct rgbcolor *rgbcolor_copy(const struct rgbcolor *prgbcolor);
68bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2);
70
71bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor,
72 char *path, ...)
75 const struct rgbcolor *prgbcolor, char *path, ...)
77
79 size_t hex_len);
81
83
84#ifdef __cplusplus
85}
86#endif /* __cplusplus */
87
88#endif /* FC__RGBCOLOR_H */
char * incite_cost
Definition comments.c:74
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, char *path,...) fc__attribute((__format__(__printf__
bool rgbcolor_from_hex(struct rgbcolor **prgbcolor, const char *hex)
Definition rgbcolor.c:162
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2)
Definition rgbcolor.c:62
bool void rgbcolor_save(struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...) fc__attribute((__format__(__printf__
struct rgbcolor * rgbcolor_copy(const struct rgbcolor *prgbcolor)
Definition rgbcolor.c:51
bool void bool rgbcolor_to_hex(const struct rgbcolor *prgbcolor, char *hex, size_t hex_len)
Definition rgbcolor.c:142
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Definition rgbcolor.c:34
int rgbcolor_brightness_score(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:196
Definition colors.h:21
int g
Definition rgbcolor.h:34
struct color * color
Definition rgbcolor.h:35
int b
Definition rgbcolor.h:34
int r
Definition rgbcolor.h:34
#define fc__attribute(x)
Definition support.h:99