|
libtcod
|
Color handling module. More...
#include <stdbool.h>#include <stdint.h>#include <istream>#include <ostream>#include <stdexcept>#include "config.h"Go to the source code of this file.
Classes | |
| struct | TCOD_ColorRGB |
| A 3-channel RGB color struct. More... | |
| struct | TCOD_ColorRGBA |
| A 4-channel RGBA color struct. More... | |
Typedefs | |
| typedef struct TCOD_ColorRGB | TCOD_color_t |
| typedef struct TCOD_ColorRGB | TCOD_ColorRGB |
| typedef struct TCOD_ColorRGBA | TCOD_ColorRGBA |
Functions | |
| TCOD_color_t | TCOD_color_RGB (uint8_t r, uint8_t g, uint8_t b) |
| Return a new TCOD_color_t from RGB values. | |
| TCOD_color_t | TCOD_color_HSV (float hue, float saturation, float value) |
| Return a new TCOD_color_t from HSV values. | |
| bool | TCOD_color_equals (TCOD_color_t c1, TCOD_color_t c2) |
| Return true value if c1 and c2 are equal. | |
| TCOD_color_t | TCOD_color_add (TCOD_color_t c1, TCOD_color_t c2) |
| Add two colors together and return the result. | |
| TCOD_color_t | TCOD_color_subtract (TCOD_color_t c1, TCOD_color_t c2) |
| Subtract c2 from c1 and return the result. | |
| TCOD_color_t | TCOD_color_multiply (TCOD_color_t c1, TCOD_color_t c2) |
| Multiply two colors together and return the result. | |
| TCOD_color_t | TCOD_color_multiply_scalar (TCOD_color_t c1, float value) |
| Multiply a color with a scalar value and return the result. | |
| TCOD_color_t | TCOD_color_lerp (TCOD_color_t c1, TCOD_color_t c2, float coef) |
| Interpolate two colors together and return the result. | |
| void | TCOD_color_set_HSV (TCOD_color_t *color, float hue, float saturation, float value) |
| Sets a colors values from HSV values. | |
| void | TCOD_color_get_HSV (TCOD_color_t color, float *hue, float *saturation, float *value) |
| Get a set of HSV values from a color. | |
| float | TCOD_color_get_hue (TCOD_color_t color) |
| Return a colors hue. | |
| void | TCOD_color_set_hue (TCOD_color_t *color, float hue) |
| Change a colors hue. | |
| float | TCOD_color_get_saturation (TCOD_color_t color) |
| Return a colors saturation. | |
| void | TCOD_color_set_saturation (TCOD_color_t *color, float saturation) |
| Change a colors saturation. | |
| float | TCOD_color_get_value (TCOD_color_t color) |
| Get a colors value. | |
| void | TCOD_color_set_value (TCOD_color_t *color, float value) |
| Change a colors value. | |
| void | TCOD_color_shift_hue (TCOD_color_t *color, float shift) |
| Shift a colors hue by an amount. | |
| void | TCOD_color_scale_HSV (TCOD_color_t *color, float saturation_coef, float value_coef) |
| Scale a colors saturation and value. | |
| void | TCOD_color_gen_map (TCOD_color_t *map, int nb_key, const TCOD_color_t *key_color, const int *key_index) |
| Generate an interpolated gradient of colors. | |
Color handling module.
| TCOD_color_t TCOD_color_add | ( | TCOD_color_t | c1, |
| TCOD_color_t | c2 ) |
Add two colors together and return the result.
| c1 | The first color. |
| c2 | The second color. |
| void TCOD_color_gen_map | ( | TCOD_color_t * | map, |
| int | nb_key, | ||
| const TCOD_color_t * | key_color, | ||
| const int * | key_index ) |
Generate an interpolated gradient of colors.
| map | Array to fill with the new gradient. |
| nb_key | The array size of the key_color and key_index parameters. |
| key_color | An array of colors to use, in order. |
| key_index | An array mapping key_color items to the map array. |
| void TCOD_color_get_HSV | ( | TCOD_color_t | color, |
| float * | hue, | ||
| float * | saturation, | ||
| float * | value ) |
Get a set of HSV values from a color.
| color | The color |
| hue | Pointer to a float, filled with the hue. (degrees) |
| saturation | Pointer to a float, filled with the saturation. (0 to 1) |
| value | Pointer to a float, filled with the value. (0 to 1) |
The hue, saturation, and value parameters can not be NULL pointers,
| float TCOD_color_get_hue | ( | TCOD_color_t | color | ) |
Return a colors hue.
| color | A color struct. |
| float TCOD_color_get_saturation | ( | TCOD_color_t | color | ) |
Return a colors saturation.
| color | A color struct. |
| float TCOD_color_get_value | ( | TCOD_color_t | color | ) |
Get a colors value.
| color | A color struct. |
| TCOD_color_t TCOD_color_HSV | ( | float | hue, |
| float | saturation, | ||
| float | value ) |
Return a new TCOD_color_t from HSV values.
| hue | The colors hue (in degrees.) |
| saturation | The colors saturation (from 0 to 1) |
| value | The colors value (from 0 to 1) |
The saturation and value parameters are automatically clamped to 0 and 1.
TCOD_color_t light_blue = TCOD_color_HSV(240.0f, 0.75f, 1.0f);
Use TCOD_color_set_HSV to fill an existing struct with HSV values.
| TCOD_color_t TCOD_color_lerp | ( | TCOD_color_t | c1, |
| TCOD_color_t | c2, | ||
| float | coef ) |
Interpolate two colors together and return the result.
| c1 | The first color (where coef if 0) |
| c2 | The second color (where coef if 1) |
| coef | The coefficient. |
| TCOD_color_t TCOD_color_multiply | ( | TCOD_color_t | c1, |
| TCOD_color_t | c2 ) |
Multiply two colors together and return the result.
| c1 | The first color. |
| c2 | The second color. |
| TCOD_color_t TCOD_color_multiply_scalar | ( | TCOD_color_t | c1, |
| float | value ) |
Multiply a color with a scalar value and return the result.
| c1 | The color to multiply. |
| value | The scalar float. |
| TCOD_color_t TCOD_color_RGB | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Return a new TCOD_color_t from RGB values.
TCOD_ColorRGB white = {255, 255, 255}; | void TCOD_color_scale_HSV | ( | TCOD_color_t * | color, |
| float | saturation_coef, | ||
| float | value_coef ) |
Scale a colors saturation and value.
| color | Pointer to a color struct. |
| saturation_coef | Multiplier for this colors saturation. |
| value_coef | Multiplier for this colors value. |
| void TCOD_color_set_HSV | ( | TCOD_color_t * | color, |
| float | hue, | ||
| float | saturation, | ||
| float | value ) |
Sets a colors values from HSV values.
| color | The color to be changed. |
| hue | The colors hue (in degrees.) |
| saturation | The colors saturation (from 0 to 1) |
| value | The colors value (from 0 to 1) |
| void TCOD_color_set_hue | ( | TCOD_color_t * | color, |
| float | hue ) |
Change a colors hue.
| color | Pointer to a color struct. |
| hue | The hue in degrees. |
| void TCOD_color_set_saturation | ( | TCOD_color_t * | color, |
| float | saturation ) |
Change a colors saturation.
| color | Pointer to a color struct. |
| saturation | The desired saturation value. |
| void TCOD_color_set_value | ( | TCOD_color_t * | color, |
| float | value ) |
Change a colors value.
| color | Pointer to a color struct. |
| value | The desired value. |
| void TCOD_color_shift_hue | ( | TCOD_color_t * | color, |
| float | shift ) |
Shift a colors hue by an amount.
| color | Pointer to a color struct. |
| hue_shift | The distance to shift the hue, in degrees. |
| TCOD_color_t TCOD_color_subtract | ( | TCOD_color_t | c1, |
| TCOD_color_t | c2 ) |
Subtract c2 from c1 and return the result.
| c1 | The first color. |
| c2 | The second color. |