Freeciv-3.3
Loading...
Searching...
No Matches
Functions
rgbcolor.c File Reference
#include <stdarg.h>
#include "fcintl.h"
#include "log.h"
#include "registry.h"
#include "fc_interface.h"
#include "game.h"
#include "rgbcolor.h"

Go to the source code of this file.

Functions

struct rgbcolorrgbcolor_new (int r, int g, int b)
 
struct rgbcolorrgbcolor_copy (const struct rgbcolor *prgbcolor)
 
bool rgbcolors_are_equal (const struct rgbcolor *c1, const struct rgbcolor *c2)
 
void rgbcolor_destroy (struct rgbcolor *prgbcolor)
 
bool rgbcolor_load (struct section_file *file, struct rgbcolor **prgbcolor, char *path,...)
 
void rgbcolor_save (struct section_file *file, const struct rgbcolor *prgbcolor, char *path,...)
 
bool rgbcolor_to_hex (const struct rgbcolor *prgbcolor, char *hex, size_t hex_len)
 
bool rgbcolor_from_hex (struct rgbcolor **prgbcolor, const char *hex)
 
int rgbcolor_brightness_score (struct rgbcolor *prgbcolor)
 

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 196 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()

void rgbcolor_destroy ( struct rgbcolor prgbcolor)

◆ rgbcolor_from_hex()

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

Convert a hex string into a rgb color

Definition at line 162 of file rgbcolor.c.

Referenced by playercolor_command().

◆ rgbcolor_load()

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

Lookup an RGB color definition ([colorpath].red, [colorpath].green and [colorpath].blue). Returns TRUE on success and FALSE on error.

Definition at line 90 of file rgbcolor.c.

Referenced by color_system_read(), load_ruleset_game(), load_ruleset_nations(), load_ruleset_terrain(), sg_load_players_basic(), and sg_load_players_basic().

◆ 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,
  ... 
)

Save an RGB color definition ([colorpath].red, [colorpath].green and [colorpath].blue).

Definition at line 121 of file rgbcolor.c.

Referenced by save_game_ruleset(), save_nation(), save_terrain_ruleset(), and sg_save_player_main().

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

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

Referenced by assign_player_colors(), and playercolor_command().