mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Add Color::brighter/darker functions
These are exposed in .60 as well as in Rust and C++ and implemented by converting to HSV color space and adjusting the brightness (value).
This commit is contained in:
parent
a42c3a0b01
commit
391d0152f0
13 changed files with 271 additions and 3 deletions
|
@ -133,6 +133,9 @@ public:
|
|||
/// Returns the alpha channel of the color as u8 in the range 0..255.
|
||||
uint8_t alpha() const { return inner.alpha; }
|
||||
|
||||
inline Color brighter(float factor) const;
|
||||
inline Color darker(float factor) const;
|
||||
|
||||
/// Returns true if \a lhs has the same values for the individual color channels as \rhs; false
|
||||
/// otherwise.
|
||||
friend bool operator==(const Color &lhs, const Color &rhs)
|
||||
|
@ -156,7 +159,7 @@ public:
|
|||
}
|
||||
|
||||
// FIXME: we need this to create GradientStop
|
||||
operator const cbindgen_private::types::Color&() { return inner; }
|
||||
operator const cbindgen_private::types::Color &() { return inner; }
|
||||
|
||||
private:
|
||||
cbindgen_private::types::Color inner;
|
||||
|
@ -164,6 +167,20 @@ private:
|
|||
friend class Brush;
|
||||
};
|
||||
|
||||
inline Color Color::brighter(float factor) const
|
||||
{
|
||||
Color result;
|
||||
cbindgen_private::types::sixtyfps_color_brighter(&inner, factor, &result.inner);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Color Color::darker(float factor) const
|
||||
{
|
||||
Color result;
|
||||
cbindgen_private::types::sixtyfps_color_darker(&inner, factor, &result.inner);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<>
|
||||
RgbaColor<uint8_t>::RgbaColor(const Color &color)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue