|
Antiprism 0.23
|
Colour holding RGBA or an index number. More...
#include <col_val.h>

Public Member Functions | |
| col_val (int idx=-2) | |
| Constructor. | |
| col_val (int red, int green, int blue, int alpha=255) | |
| Constructor. | |
| col_val (vec3d col) | |
| Constructor. | |
| col_val (vec4d col) | |
| Constructor. | |
| col_val (double red, double green, double blue, double alpha=1.0) | |
| Constructor. | |
| void | unset () |
| Unset the colour, indicating no colour is set. | |
| void | set_idx (int idx=-2) |
| Set the colour with an index number. | |
| void | set_rgba (int red, int green, int blue, int alpha=255) |
| Set the colour with integer RGBA values. | |
| void | set_rgba (double red, double green, double blue, double alpha=1.0) |
| Set the colour with floating point RGBA values. | |
| void | set_hsva (double hue, double sat, double val, double alpha=1.0) |
| Set the colour with floating point HSVA values. | |
| void | set_hsva (const vec4d &hsva) |
| Set the colour with floating point HSVA values. | |
| void | set_hsla (double hue, double sat, double lum, double alpha=1.0) |
| Set the colour with floating point hsla values. | |
| void | set_hsla (const vec4d &hsla) |
| Set the colour with floating point hsla values. | |
| void | set_complement (col_val col=col_val()) |
| Set the colour to its complement, or the complement of another colour. | |
| void | set_brightness (double brt_val, col_val col=col_val()) |
| Set the colour brightness, or from brightening another colour. | |
| int | get_idx () const |
| Get the index number. | |
| int | get_trans () const |
| Get the transparency in integer format. | |
| double | get_transd () const |
| Get the transparency in floating point format. | |
| vec3d | get_vec3d () const |
| Get the RGB values. | |
| vec4d | get_vec4d () const |
| Get the RGBA values. | |
| unsigned long | get_long () const |
| Get the RGBA values as a long integer. | |
| vec4d | get_hsva () const |
| Get the HSVA values. | |
| vec4d | get_hsla () const |
| Get the HSLA values. | |
| int | operator[] (int i) const |
| Read access to the integer RGBA values. | |
| bool | is_set () const |
| Check whether a colour is set. | |
| bool | is_val () const |
| Check whether a colour is held as RGBA. | |
| bool | is_idx () const |
| Check whether a colour is held as an index number. | |
| bool | is_def () const |
| Check whether a colour has the default unset colour state. | |
| bool | is_inv () const |
| Check whether a colour is invisible. | |
| bool | operator== (col_val c) const |
| Check for equality. | |
| bool | operator!= (col_val c) const |
| Check for inequality. | |
| bool | read (char *col_str, char *errmsg=0) |
| Read a colour given as text, detecting the format. | |
| bool | from_offvals (vector< char * > &vals, char *errmsg=0, int *col_type=0) |
| Read an OFF colour given as number strings. | |
| bool | from_decvals (vector< double > &vals, char *errmsg=0) |
| Read a colour given as floating point values. | |
| bool | from_intvals (vector< int > &vals, char *errmsg=0) |
| Read a colour given as integers. | |
| bool | read_decvals (vector< char * > &vals, char *errmsg=0) |
| Read a colour given as decimal strings. | |
| bool | read_intvals (vector< char * > &vals, char *errmsg=0) |
| Read a colour given as integer strings. | |
| bool | read_decvals (char *str, char *errmsg=0) |
| Read a colour given as decimals in a string. | |
| bool | read_intvals (char *str, char *errmsg=0) |
| Read a colour given as integers in a string. | |
| bool | read_hexvals (char *str, char *errmsg=0) |
| Read a colour given as hex format in a string. | |
| bool | read_hsva_vals (char *str, char *errmsg=0) |
| Read a colour given as HSVA format in a string. | |
| bool | read_colorname (char *str, char *errmsg=0, bool as_index=false) |
| Read a colour given by name. | |
| void | dump (const char *var="", FILE *file=stderr) const |
| Debugging print of a vector variable. | |
Static Public Member Functions | |
| static int | f2i (double f) |
| Convert from floating point to integer format. | |
| static double | i2f (int i) |
| Convert from integer to floating point format. | |
| static bool | check (int i) |
| Check that an integer is in the valid colour range. | |
| static bool | in_range (int r, int g, int b, int a) |
| Check that integer components are in the valid colour range. | |
Static Public Attributes | |
| static col_val | invisible |
| The invisible colour for non-display elements. | |
Colour holding RGBA or an index number.
| col_val::col_val | ( | int | idx = -2 | ) | [inline] |
Constructor.
Initialise with an index number
| idx | a positive index number (default value -2 indicates that no colour is set) |
| col_val::col_val | ( | int | red, |
| int | green, | ||
| int | blue, | ||
| int | alpha = 255 |
||
| ) | [inline] |
Constructor.
Initialise with integer RGBA values. Using out of range values will leave the colour unset.
| red | red value in range 0 - 255 |
| green | green value in range 0 - 255 |
| blue | blue value in range 0 - 255 |
| alpha | alpha value in range 0 (clear) - 255 (opaque) |
| col_val::col_val | ( | vec3d | col | ) | [inline] |
Constructor.
Initialise with RGB values in a vec3d. Using out of range values will leave the colour unset.
| col | components hold in turn the red, green and blue values, in the range 0.0 to 1.0 |
| col_val::col_val | ( | vec4d | col | ) | [inline] |
Constructor.
Initialise with RGBA values in a vec4d. Using out of range values will leave the colour unset.
| col | components hold in turn the red, green, blue and alpha values, in the range 0.0 to 1.0 |
| col_val::col_val | ( | double | red, |
| double | green, | ||
| double | blue, | ||
| double | alpha = 1.0 |
||
| ) | [inline] |
Constructor.
Initialise with floating point RGBA values. Using out of range values will leave the colour unset.
| red | red value in range 0.0 - 1.0 |
| green | green value in range 0.0 - 1.0 |
| blue | blue value in range 0.0 - 1.0 |
| alpha | alpha value in range 0.0 (clear) - 1.0 (opaque) |
| bool col_val::check | ( | int | i | ) | [inline, static] |
Check that an integer is in the valid colour range.
| i | number to check. |
true if i is in range 0 - 255, otherwise false. | void col_val::dump | ( | const char * | var = "", |
| FILE * | file = stderr |
||
| ) | const |
Debugging print of a vector variable.
| var | a string to identify the vector variable. |
| file | file stream to print the variable. |
| int col_val::f2i | ( | double | f | ) | [inline, static] |
Convert from floating point to integer format.
| f | a floating point number in range 0.0 - 1.0. |
0 - 255 | bool col_val::from_decvals | ( | vector< double > & | vals, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as floating point values.
| vals | 3 (RGB) or 4 (RGBA) values in range 0.0 - 1.0. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::from_intvals | ( | vector< int > & | vals, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as integers.
| vals | 3 (RGB) or 4 (RGBA) values in range 0 - 255. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::from_offvals | ( | vector< char * > & | vals, |
| char * | errmsg = 0, |
||
| int * | col_type = 0 |
||
| ) |
Read an OFF colour given as number strings.
Read decimal values, integer values or an index number
| vals | numbers held as strings. |
| errmsg | an array at least MSG_SZ chars long to return an error message if col_type is 0. |
| col_type | used to return the colour type that was read
|
| vec4d col_val::get_hsla | ( | ) | const |
Get the HSLA values.
0.0 to 1.0. | vec4d col_val::get_hsva | ( | ) | const |
Get the HSVA values.
0.0 to 1.0. | int col_val::get_idx | ( | ) | const [inline] |
Get the index number.
| unsigned long col_val::get_long | ( | ) | const [inline] |
Get the RGBA values as a long integer.
| int col_val::get_trans | ( | ) | const [inline] |
Get the transparency in integer format.
0 (opaque) - 255 (clear). | double col_val::get_transd | ( | ) | const [inline] |
Get the transparency in floating point format.
0.0 (opaque) - 1.0 (clear). | vec3d col_val::get_vec3d | ( | ) | const [inline] |
Get the RGB values.
0.0 to 1.0. | vec4d col_val::get_vec4d | ( | ) | const [inline] |
Get the RGBA values.
0.0 to 1.0. | double col_val::i2f | ( | int | i | ) | [inline, static] |
Convert from integer to floating point format.
| i | an integer in range 0 - 255. |
0.0 - 1.0 | bool col_val::in_range | ( | int | r, |
| int | g, | ||
| int | b, | ||
| int | a | ||
| ) | [inline, static] |
Check that integer components are in the valid colour range.
| r | the red component. |
| g | the green component. |
| b | the blue component. |
| a | the alpha component. |
true if all components are in the range 0 - 255, otherwise false. | bool col_val::is_def | ( | ) | const [inline] |
Check whether a colour has the default unset colour state.
The opposite of is_set()
true if the colour has not been set to a valid value, otherwise false. | bool col_val::is_idx | ( | ) | const [inline] |
Check whether a colour is held as an index number.
true if the colour holds an index number, otherwise false. | bool col_val::is_inv | ( | ) | const [inline] |
Check whether a colour is invisible.
true if the colour holds the invisible colour value, otherwise false. | bool col_val::is_set | ( | ) | const [inline] |
Check whether a colour is set.
true if the colour has been set to a valid value, otherwise false. | bool col_val::is_val | ( | ) | const [inline] |
Check whether a colour is held as RGBA.
true if the colour holds an RGB value, otherwise false. | bool col_val::operator!= | ( | col_val | c | ) | const [inline] |
Check for inequality.
| bool col_val::operator== | ( | col_val | c | ) | const |
Check for equality.
| bool col_val::read | ( | char * | col_str, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as text, detecting the format.
Will read any of the formats below that work with a string
| col_str | the color string. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_colorname | ( | char * | str, |
| char * | errmsg = 0, |
||
| bool | as_index = false |
||
| ) |
Read a colour given by name.
| str | the colour name to be looked up in the internal list of colours. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| as_index | if true then set the colour as the colour index number in the X11 color map. |
| bool col_val::read_decvals | ( | char * | str, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as decimals in a string.
| str | a string of 3 (RGB) or 4 (RGBA) comma separated decimals in range 0.0 - 1.0. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_decvals | ( | vector< char * > & | vals, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as decimal strings.
| vals | 3 (RGB) or 4 (RGBA) numbers in range 0.0 - 1.0 held as strings. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_hexvals | ( | char * | str, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as hex format in a string.
| str | a string starting with X, x or # followed by 3 (RGB) or 4 (RGBA) pairs of hexadecimal digits representing integers in range 0 - 255. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_hsva_vals | ( | char * | str, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as HSVA format in a string.
| str | a string starting with H or h followed by param str a string of 1 (h) value of plus/minus N degrees or 1 (H) decimal value in range 0.0 - 1.0. and up to 3 (SVA) optional comma separated decimals in range 0.0 - 1.0. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_intvals | ( | vector< char * > & | vals, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as integer strings.
| vals | 3 (RGB) or 4 (RGBA) numbers in range 0 - 255 held as strings. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
| bool col_val::read_intvals | ( | char * | str, |
| char * | errmsg = 0 |
||
| ) |
Read a colour given as integers in a string.
| str | a string of 3 (RGB) or 4 (RGBA) comma separated integers in range 0 - 255. |
| errmsg | an array at least MSG_SZ chars long to return any error message. |
Set the colour brightness, or from brightening another colour.
| brt_val | the value to brighten in the range -1.0 to 1.0. Positive values brighten towards white and negative values darken towards black |
| col | the colour as the base to brighten, or use current colour if col is unset (default). If col is an index the final colour will be unset |
Set the colour to its complement, or the complement of another colour.
| col | the colour to take the complement from, or use current colour if col is unset (default). If col is an index the final colour will be unset |
| void col_val::set_hsla | ( | const vec4d & | hsla | ) |
Set the colour with floating point hsla values.
The hsla values are in the range 0.0-1.0. Using out of range values will leave the colour unset.
| void col_val::set_hsla | ( | double | hue, |
| double | sat, | ||
| double | lum, | ||
| double | alpha = 1.0 |
||
| ) |
Set the colour with floating point hsla values.
Using out of range values will leave the colour unset.
| hue | hue in range 0.0 - 1.0 |
| sat | saturation in range 0.0 - 1.0 |
| lum | value in range 0.0 - 1.0 |
| alpha | alpha value in range 0.0 (clear) - 1.0 (opaque) |
| void col_val::set_hsva | ( | double | hue, |
| double | sat, | ||
| double | val, | ||
| double | alpha = 1.0 |
||
| ) |
Set the colour with floating point HSVA values.
Using out of range values will leave the colour unset.
| hue | hue in range 0.0 - 1.0 |
| sat | saturation in range 0.0 - 1.0 |
| val | value in range 0.0 - 1.0 |
| alpha | alpha value in range 0.0 (clear) - 1.0 (opaque) |
| void col_val::set_hsva | ( | const vec4d & | hsva | ) |
Set the colour with floating point HSVA values.
The HSVA values are in the range 0.0-1.0. Using out of range values will leave the colour unset.
| void col_val::set_idx | ( | int | idx = -2 | ) | [inline] |
Set the colour with an index number.
| idx | a positive index number (default value -2 indicates that no colour is set) |
| void col_val::set_rgba | ( | double | red, |
| double | green, | ||
| double | blue, | ||
| double | alpha = 1.0 |
||
| ) | [inline] |
Set the colour with floating point RGBA values.
Using out of range values will leave the colour unset.
| red | red value in range 0.0 - 1.0 |
| green | green value in range 0.0 - 1.0 |
| blue | blue value in range 0.0 - 1.0 |
| alpha | alpha value in range 0.0 (clear) - 1.0 (opaque) |
| void col_val::set_rgba | ( | int | red, |
| int | green, | ||
| int | blue, | ||
| int | alpha = 255 |
||
| ) | [inline] |
Set the colour with integer RGBA values.
Using out of range values will leave the colour unset.
| red | red value in range 0 - 255 |
| green | green value in range 0 - 255 |
| blue | blue value in range 0 - 255 |
| alpha | alpha value in range 0 (clear) - 255 (opaque) |
1.7.3