Freeciv-3.4
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
rgbcolor.h File Reference
#include "shared.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

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)
 
struct rgbcolorrgbcolor_copy (const struct rgbcolor *prgbcolor) fc__attribute((nonnull(1)))
 
bool rgbcolors_are_equal (const struct rgbcolor *c1, const struct rgbcolor *c2) fc__attribute((nonnull(1
 
bool void rgbcolor_destroy (struct rgbcolor *prgbcolor)
 
bool rgbcolor_load (struct section_file *file, struct rgbcolor **prgbcolor, char *path,...) fc__attribute((__format__(__printf__
 
bool fc__attribute ((nonnull(1)))
 
void rgbcolor_save (struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...) fc__attribute((__format__(__printf__
 
void fc__attribute ((nonnull(1, 2)))
 
bool rgbcolor_to_hex (const struct rgbcolor *prgbcolor, char *hex, size_t hex_len) fc__attribute((nonnull(1)))
 
bool rgbcolor_from_hex (struct rgbcolor **prgbcolor, const char *hex) fc__attribute((nonnull(1
 
bool int rgbcolor_brightness_score (struct rgbcolor *prgbcolor)
 

Macro Definition Documentation

◆ CHECK_RGBCOLOR

#define CHECK_RGBCOLOR (   _str,
  _c,
  _colorname 
)
Value:
{ \
int _color_save = _c; \
\
_c = CLIP(0, _c, 255); \
log_error("Invalid value for '%s' in color definition '%s' (%d). " \
"Setting it to '%d'.", _colorname, _str, _color_save, _c); \
} \
}
char * incite_cost
Definition comments.c:77
#define CLIP(lower, current, upper)
Definition shared.h:57

Definition at line 49 of file rgbcolor.h.

◆ rgbcolor_check

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

Definition at line 59 of file rgbcolor.h.

◆ rgbcolor_list_iterate

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

Definition at line 43 of file rgbcolor.h.

◆ rgbcolor_list_iterate_end

#define rgbcolor_list_iterate_end   LIST_ITERATE_END

Definition at line 45 of file rgbcolor.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   rgbcolor

Definition at line 39 of file rgbcolor.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct rgbcolor

Definition at line 40 of file rgbcolor.h.

Function Documentation

◆ fc__attribute() [1/2]

bool fc__attribute ( (nonnull(1))  )

◆ fc__attribute() [2/2]

void fc__attribute ( (nonnull(1, 2))  )

◆ rgbcolor_brightness_score()

bool 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 186 of file rgbcolor.c.

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 51 of file rgbcolor.c.

Referenced by player_set_color().

◆ rgbcolor_destroy()

bool void rgbcolor_destroy ( struct rgbcolor prgbcolor)

◆ rgbcolor_from_hex()

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

◆ rgbcolor_load()

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

◆ rgbcolor_new()

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

◆ rgbcolor_save()

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

◆ rgbcolor_to_hex()

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 134 of file rgbcolor.c.

Referenced by player_color_ftstr().

◆ rgbcolors_are_equal()

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