Class Colorο
Defined in File slint_color.h
Class Documentationο
-
class Colorο
Color represents a color in the Slint run-time, represented using 8-bit channels for red, green, blue and the alpha (opacity).
Public Functions
-
inline Color()ο
Default constructs a new color that is entirely transparent.
-
inline Color(const RgbaColor<uint8_t> &col)ο
Constructs a new color from the given RgbaColor<uint8_t> col.
-
inline Color(const RgbaColor<float> &col)ο
Constructs a new color from the given RgbaColor<float> col.
-
inline uint32_t as_argb_encoded() constο
Returns
(alpha, red, green, blue)
encoded as uint32_t.
-
inline RgbaColor<uint8_t> to_argb_uint() constο
Converts this color to an RgbaColor struct for easy destructuring.
-
inline RgbaColor<float> to_argb_float() constο
Converts this color to an RgbaColor struct for easy destructuring.
-
inline uint8_t red() constο
Returns the red channel of the color as u8 in the range 0..255.
-
inline uint8_t green() constο
Returns the green channel of the color as u8 in the range 0..255.
-
inline uint8_t blue() constο
Returns the blue channel of the color as u8 in the range 0..255.
-
inline uint8_t alpha() constο
Returns the alpha channel of the color as u8 in the range 0..255.
-
inline Color brighter(float factor) constο
Returns a new version of this color that has the brightness increased by the specified factor. This is done by converting the color to the HSV color space and multiplying the brightness (value) with (1 + factor). The result is converted back to RGB and the alpha channel is unchanged. So for example
brighter(0.2)
will increase the brightness by 20%, and callingbrighter(-0.5)
will return a color thatβs 50% darker.
-
inline Color darker(float factor) constο
Returns a new version of this color that has the brightness decreased by the specified factor. This is done by converting the color to the HSV color space and dividing the brightness (value) by (1 + factor). The result is converted back to RGB and the alpha channel is unchanged. So for example
darker(0.3)
will decrease the brightness by 30%.
Public Static Functions
-
static inline Color from_argb_encoded(uint32_t argb_encoded)ο
Construct a color from an integer encoded as
0xAARRGGBB
-
static inline Color from_argb_uint8(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue)ο
Construct a color from the alpha, red, green and blue color channel parameters.
-
static inline Color from_rgb_uint8(uint8_t red, uint8_t green, uint8_t blue)ο
Construct a color from the red, green and blue color channel parameters. The alpha channel will have the value 255.
-
inline Color()ο