Struct slint::Color

pub struct Color { /* private fields */ }
Expand description

Color represents a color in the Slint run-time, represented using 8-bit channels for red, green, blue and the alpha (opacity). It can be conveniently converted using the to_ and from_ (a)rgb helper functions:

let col = some_color.to_argb_f32();
do_something_with_red_and_green(col.red, col.green);

let RgbaColor { red, blue, green, .. } = some_color.to_argb_u8();
do_something_with_red(red);

let new_col = Color::from(RgbaColor{ red: 0.5, green: 0.65, blue: 0.32, alpha: 1.});

Implementationsยง

Construct a color from an integer encoded as 0xAARRGGBB

Returns (alpha, red, green, blue) encoded as u32

Construct a color from the alpha, red, green and blue color channel parameters.

Construct a color from the red, green and blue color channel parameters. The alpha channel will have the value 255.

Construct a color from the alpha, red, green and blue color channel parameters.

Construct a color from the red, green and blue color channel parameters. The alpha channel will have the value 255.

Converts this color to an RgbaColor struct for easy destructuring.

Converts this color to an RgbaColor struct for easy destructuring.

Returns the red channel of the color as u8 in the range 0..255.

Returns the green channel of the color as u8 in the range 0..255.

Returns the blue channel of the color as u8 in the range 0..255.

Returns the alpha channel of the color as u8 in the range 0..255.

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 calling brighter(-0.5) will return a color thatโ€™s 50% darker.

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%.

Trait Implementationsยง

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the โ€œdefault valueโ€ for a type. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.

Convert a non-premultiplied color to a premultiplied one

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Returns the interpolated value between self and target_value according to the progress parameter t thatโ€™s usually between 0 and 1. With certain animation easing curves it may over- or undershoot though. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Checks that type has a default value.
The none-equivalent value.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more