c-color-names  v0.1.0-alpha.1
Color Names API in C
Functions
color_names.h File Reference

c-color-names main header file. Defines the API of c-color-names. More...

#include <stdint.h>

Go to the source code of this file.

Functions

int color_name_exists (const char *color_name)
 
int color_name_get_rgb_string (const char *color_name, char *color_hex_str)
 
int color_name_get_rgb (const char *color_name, uint8_t *r, uint8_t *g, uint8_t *b)
 
const char * color_name_find_rgb (uint8_t r, uint8_t g, uint8_t b)
 
int color_name_get_hsv (const char *color_name, float *h, float *s, float *v)
 
const char * color_name_find_hsv (float h, float s, float v)
 
const char * color_name_find_hex (const char *hex)
 

Detailed Description

c-color-names main header file. Defines the API of c-color-names.

Function Documentation

◆ color_name_exists()

int color_name_exists ( const char *  color_name)

check if the name exists in the color list. color name should be lowercase, other wise match might fail.

Parameters
color_namename of the color to look for (lowercase chars only)
Returns
int 0 or 1 indicating whether color name found

◆ color_name_find_hex()

const char* color_name_find_hex ( const char *  hex)

find the color name for the given color hex string in format #rrggbb. returns NULL if color is not found.

Parameters
hexhex string (format #rrggbb) of the color to be looked up. must be exactly 7 chars in length.
Returns
color name (NULL if not found)

◆ color_name_find_hsv()

const char* color_name_find_hsv ( float  h,
float  s,
float  v 
)

find the color name for the given h,s,v triplet. returns NULL if color is not found.

Parameters
hhue
ssaturation
vvalue
Returns
color name (NULL if not found)

◆ color_name_find_rgb()

const char* color_name_find_rgb ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

find the color name for the given r,g,b triplet. returns NULL if color is not found.

Parameters
rred value
ggreen value
bblue value
Returns
color name (NULL if not found)

◆ color_name_get_hsv()

int color_name_get_hsv ( const char *  color_name,
float *  h,
float *  s,
float *  v 
)

find the hsv values for the given color name if found

Parameters
color_namename of the color to look for (lowercase chars only)
hhue
ssaturation
vvalue
Returns
int 0 or 1 indicating whether color name found.

◆ color_name_get_rgb()

int color_name_get_rgb ( const char *  color_name,
uint8_t *  r,
uint8_t *  g,
uint8_t *  b 
)

find the rgb values for the given color name if found

Parameters
color_namename of the color to look for (lowercase chars only)
rred value
ggreen value
bblue value
Returns
int 0 or 1 indicating whether color name found.

◆ color_name_get_rgb_string()

int color_name_get_rgb_string ( const char *  color_name,
char *  color_hex_str 
)

find the hex string for the given color name if found

Parameters
color_namename of the color to look for (lowercase chars only)
color_hexstrstring of length 8. it will contain the hexstring in format #xxxxxx if color name found, unchanged otherwise.
Returns
int 0 or 1 indicating whether color name found