summaryrefslogtreecommitdiffstats
path: root/style/src/theme
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
commit633f405f3f78bc7f82d2b2061491b0e011137451 (patch)
tree5ebfc1f45d216a5c14a90492563599e6969eab4d /style/src/theme
parent41836dd80d0534608e7aedfbf2319c540a23de1a (diff)
parent21bd51426d900e271206f314e0c915dd41065521 (diff)
downloadiced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz
iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2
iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
Diffstat (limited to 'style/src/theme')
-rw-r--r--style/src/theme/palette.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs
index 0f15494b..aaeb799d 100644
--- a/style/src/theme/palette.rs
+++ b/style/src/theme/palette.rs
@@ -2,7 +2,9 @@
use iced_core::Color;
use once_cell::sync::Lazy;
-use palette::{FromColor, Hsl, Mix, RelativeContrast, Srgb};
+use palette::color_difference::Wcag21RelativeContrast;
+use palette::rgb::Rgb;
+use palette::{FromColor, Hsl, Mix};
/// A color palette.
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -298,11 +300,11 @@ fn deviate(color: Color, amount: f32) -> Color {
}
fn mix(a: Color, b: Color, factor: f32) -> Color {
- let a_lin = Srgb::from(a).into_linear();
- let b_lin = Srgb::from(b).into_linear();
+ let a_lin = Rgb::from(a).into_linear();
+ let b_lin = Rgb::from(b).into_linear();
- let mixed = a_lin.mix(&b_lin, factor);
- Srgb::from_linear(mixed).into()
+ let mixed = a_lin.mix(b_lin, factor);
+ Rgb::from_linear(mixed).into()
}
fn readable(background: Color, text: Color) -> Color {
@@ -320,16 +322,16 @@ fn is_dark(color: Color) -> bool {
}
fn is_readable(a: Color, b: Color) -> bool {
- let a_srgb = Srgb::from(a);
- let b_srgb = Srgb::from(b);
+ let a_srgb = Rgb::from(a);
+ let b_srgb = Rgb::from(b);
- a_srgb.has_enhanced_contrast_text(&b_srgb)
+ a_srgb.has_enhanced_contrast_text(b_srgb)
}
fn to_hsl(color: Color) -> Hsl {
- Hsl::from_color(Srgb::from(color))
+ Hsl::from_color(Rgb::from(color))
}
fn from_hsl(hsl: Hsl) -> Color {
- Srgb::from_color(hsl).into()
+ Rgb::from_color(hsl).into()
}