1 | #pragma once |
2 | |
3 | /* Generated with cbindgen:0.26.0 */ |
4 | |
5 | #include <cstdarg> |
6 | #include <cstdint> |
7 | #include <cstdlib> |
8 | #include <ostream> |
9 | #include <new> |
10 | #include "slint_enums_internal.h" |
11 | |
12 | namespace slint { |
13 | namespace cbindgen_private { |
14 | namespace types { |
15 | |
16 | /// Color represents a color in the Slint run-time, represented using 8-bit channels for |
17 | /// red, green, blue and the alpha (opacity). |
18 | /// It can be conveniently converted using the `to_` and `from_` (a)rgb helper functions: |
19 | /// ``` |
20 | /// # fn do_something_with_red_and_green(_:f32, _:f32) {} |
21 | /// # fn do_something_with_red(_:u8) {} |
22 | /// # use i_slint_core::graphics::{Color, RgbaColor}; |
23 | /// # let some_color = Color::from_rgb_u8(0, 0, 0); |
24 | /// let col = some_color.to_argb_f32(); |
25 | /// do_something_with_red_and_green(col.red, col.green); |
26 | /// |
27 | /// let RgbaColor { red, blue, green, .. } = some_color.to_argb_u8(); |
28 | /// do_something_with_red(red); |
29 | /// |
30 | /// let new_col = Color::from(RgbaColor{ red: 0.5, green: 0.65, blue: 0.32, alpha: 1.}); |
31 | /// ``` |
32 | struct Color { |
33 | uint8_t red; |
34 | uint8_t green; |
35 | uint8_t blue; |
36 | uint8_t alpha; |
37 | |
38 | bool operator==(const Color& other) const { |
39 | return red == other.red && |
40 | green == other.green && |
41 | blue == other.blue && |
42 | alpha == other.alpha; |
43 | } |
44 | bool operator!=(const Color& other) const { |
45 | return red != other.red || |
46 | green != other.green || |
47 | blue != other.blue || |
48 | alpha != other.alpha; |
49 | } |
50 | }; |
51 | |
52 | extern "C" { |
53 | |
54 | void slint_color_brighter(const Color *col, float factor, Color *out); |
55 | |
56 | void slint_color_darker(const Color *col, float factor, Color *out); |
57 | |
58 | void slint_color_transparentize(const Color *col, float factor, Color *out); |
59 | |
60 | void slint_color_mix(const Color *col1, const Color *col2, float factor, Color *out); |
61 | |
62 | void slint_color_with_alpha(const Color *col, float alpha, Color *out); |
63 | |
64 | } // extern "C" |
65 | |
66 | } // namespace types |
67 | } // namespace cbindgen_private |
68 | } // namespace slint |
69 | |