Freeciv21
Develop your civilization from humble roots to a global empire
rgbcolor.h File Reference
#include "shared.h"
#include "speclist.h"
+ Include dependency graph for rgbcolor.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rgbcolor
 

Macros

#define SPECLIST_TAG   rgbcolor
 
#define SPECLIST_TYPE   struct rgbcolor
 
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)    TYPED_LIST_ITERATE(struct rgbcolor, rgbcolorlist, prgbcolor)
 
#define rgbcolor_list_iterate_end   LIST_ITERATE_END
 
#define CHECK_RGBCOLOR(_str, _c, _colorname)
 
#define rgbcolor_check(_str, _r, _g, _b)
 

Functions

struct rgbcolorrgbcolor_new (int r, int g, int b)
 Allocate new rgbcolor structure. More...
 
struct rgbcolorrgbcolor_copy (const struct rgbcolor *prgbcolor)
 Allocate new rgbcolor structure and make it copy of one given as input. More...
 
bool rgbcolors_are_equal (const struct rgbcolor *c1, const struct rgbcolor *c2)
 Test whether two rgbcolor structures represent the exact same color value. More...
 
void rgbcolor_destroy (struct rgbcolor *prgbcolor)
 Free rgbcolor structure. More...
 
bool rgbcolor_load (struct section_file *file, struct rgbcolor **prgbcolor, const char *path,...) fc__attribute((__format__(__printf__
 
bool void rgbcolor_save (struct section_file *file, const struct rgbcolor *prgbcolor, const char *path,...) fc__attribute((__format__(__printf__
 
bool void bool rgbcolor_to_hex (const struct rgbcolor *prgbcolor, char *hex, size_t hex_len)
 Convert a rgb color to a hex string (like 0xff0000 for red [255, 0, 0]). More...
 
bool rgbcolor_from_hex (struct rgbcolor **prgbcolor, const char *hex)
 Convert a hex string into a rgb color. More...
 
int rgbcolor_brightness_score (struct rgbcolor *prgbcolor)
 Return a number indicating the perceptual brightness of this color relative to others (larger is brighter). More...
 

Macro Definition Documentation

◆ CHECK_RGBCOLOR

#define CHECK_RGBCOLOR (   _str,
  _c,
  _colorname 
)
Value:
{ \
int _color_save = _c; \
\
_c = CLIP(0, _c, 255); \
if (_c != _color_save) { \
qCritical("Invalid value for '%s' in color definition '%s' (%d). " \
"Setting it to '%d'.", \
_colorname, _str, _color_save, _c); \
} \
}
#define CLIP(lower, current, upper)
Definition: shared.h:51

Definition at line 41 of file rgbcolor.h.

◆ rgbcolor_check

#define rgbcolor_check (   _str,
  _r,
  _g,
  _b 
)
Value:
{ \
CHECK_RGBCOLOR(_str, _r, "red"); \
CHECK_RGBCOLOR(_str, _g, "green"); \
CHECK_RGBCOLOR(_str, _b, "blue"); \
}

Definition at line 52 of file rgbcolor.h.

◆ rgbcolor_list_iterate

#define rgbcolor_list_iterate (   rgbcolorlist,
  prgbcolor 
)     TYPED_LIST_ITERATE(struct rgbcolor, rgbcolorlist, prgbcolor)

Definition at line 35 of file rgbcolor.h.

◆ rgbcolor_list_iterate_end

#define rgbcolor_list_iterate_end   LIST_ITERATE_END

Definition at line 37 of file rgbcolor.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   rgbcolor

Definition at line 31 of file rgbcolor.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct rgbcolor

Definition at line 32 of file rgbcolor.h.

Function Documentation

◆ rgbcolor_brightness_score()

int rgbcolor_brightness_score ( struct rgbcolor prgbcolor)

Return a number indicating the perceptual brightness of this color relative to others (larger is brighter).

Definition at line 185 of file rgbcolor.cpp.

Referenced by color_brightness_score().

◆ rgbcolor_copy()

struct rgbcolor* rgbcolor_copy ( const struct rgbcolor prgbcolor)

Allocate new rgbcolor structure and make it copy of one given as input.

Return new one.

Definition at line 41 of file rgbcolor.cpp.

Referenced by player_set_color().

◆ rgbcolor_destroy()

◆ rgbcolor_from_hex()

bool rgbcolor_from_hex ( struct rgbcolor **  prgbcolor,
const char *  hex 
)

Convert a hex string into a rgb color.

Definition at line 151 of file rgbcolor.cpp.

Referenced by playercolor_command().

◆ rgbcolor_load()

bool rgbcolor_load ( struct section_file file,
struct rgbcolor **  prgbcolor,
const char *  path,
  ... 
)

◆ rgbcolor_new()

struct rgbcolor* rgbcolor_new ( int  r,
int  g,
int  b 
)

◆ rgbcolor_save()

bool void rgbcolor_save ( struct section_file file,
const struct rgbcolor prgbcolor,
const char *  path,
  ... 
)

◆ rgbcolor_to_hex()

bool void bool rgbcolor_to_hex ( const struct rgbcolor prgbcolor,
char *  hex,
size_t  hex_len 
)

Convert a rgb color to a hex string (like 0xff0000 for red [255, 0, 0]).

Definition at line 130 of file rgbcolor.cpp.

Referenced by player_color_ftstr().

◆ rgbcolors_are_equal()

bool rgbcolors_are_equal ( const struct rgbcolor c1,
const struct rgbcolor c2 
)

Test whether two rgbcolor structures represent the exact same color value.

(Does not attempt to determine whether they are visually distinguishable.)

Definition at line 52 of file rgbcolor.cpp.

Referenced by assign_player_colors(), and playercolor_command().