mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
feat: color: add HSV methods to slint
This commit is contained in:
parent
ae2e0197f8
commit
d4a3f77877
11 changed files with 236 additions and 1 deletions
|
@ -3051,6 +3051,15 @@ fn compile_builtin_function_call(
|
|||
BuiltinFunction::ColorRgbaStruct => {
|
||||
format!("{}.to_argb_uint()", a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::ColorHue => {
|
||||
format!("{}.hue()", a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::ColorSaturation => {
|
||||
format!("{}.saturation()", a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::ColorBrightness => {
|
||||
format!("{}.brightness()", a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::ColorBrighter => {
|
||||
format!("{}.brighter({})", a.next().unwrap(), a.next().unwrap())
|
||||
}
|
||||
|
@ -3080,6 +3089,14 @@ fn compile_builtin_function_call(
|
|||
a = a.next().unwrap(),
|
||||
)
|
||||
}
|
||||
BuiltinFunction::Hsv => {
|
||||
format!("slint::Color::from_hsva(std::clamp(static_cast<float>({h}), 0., 360.), std::clamp(static_cast<float>({s}), 0., 1.), std::clamp(static_cast<float>({v}), 0., 1.), std::clamp(static_cast<float>({a}) * 1., 0., 1.))",
|
||||
h = a.next().unwrap(),
|
||||
s = a.next().unwrap(),
|
||||
v = a.next().unwrap(),
|
||||
a = a.next().unwrap(),
|
||||
)
|
||||
}
|
||||
BuiltinFunction::ColorScheme => {
|
||||
format!("{}.color_scheme()", access_window_field(ctx))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue