aboutsummaryrefslogtreecommitdiff
path: root/src/layout/focus_ring.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-07-16 10:22:03 +0300
committerGitHub <noreply@github.com>2024-07-16 07:22:03 +0000
commit3ace97660fde7fe1f0cc07a3925d1114af9a9c2f (patch)
tree9d736a1d403875737566ad8817bb347a9e8056fe /src/layout/focus_ring.rs
parent0824737757d10cbeb844871c3f67756ca969cf7c (diff)
downloadniri-3ace97660fde7fe1f0cc07a3925d1114af9a9c2f.tar.gz
niri-3ace97660fde7fe1f0cc07a3925d1114af9a9c2f.tar.bz2
niri-3ace97660fde7fe1f0cc07a3925d1114af9a9c2f.zip
Implement gradient color interpolation option (#548)
* Added the better color averaging code (tested & functional) * rustfmt * Make Color f32 0..1, clarify premul/unpremul * Fix imports and test name * Premultiply gradient colors matching CSS * Fix indentation * fixup * Add gradient image --------- Co-authored-by: K's Thinkpad <K.T.Kraft@protonmail.com>
Diffstat (limited to 'src/layout/focus_ring.rs')
-rw-r--r--src/layout/focus_ring.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/layout/focus_ring.rs b/src/layout/focus_ring.rs
index 97a1b75a..7cd73760 100644
--- a/src/layout/focus_ring.rs
+++ b/src/layout/focus_ring.rs
@@ -1,7 +1,7 @@
use std::iter::zip;
use arrayvec::ArrayVec;
-use niri_config::{CornerRadius, Gradient, GradientRelativeTo};
+use niri_config::{CornerRadius, Gradient, GradientInterpolation, GradientRelativeTo};
use smithay::backend::renderer::element::Kind;
use smithay::utils::{Logical, Point, Rectangle, Size};
@@ -72,7 +72,7 @@ impl FocusRing {
};
for buf in &mut self.buffers {
- buf.set_color(color.into());
+ buf.set_color(color.to_array_premul());
}
let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32);
@@ -91,6 +91,7 @@ impl FocusRing {
to: color,
angle: 0,
relative_to: GradientRelativeTo::Window,
+ in_: GradientInterpolation::default(),
});
let full_rect = Rectangle::from_loc_and_size((-width, -width), self.full_size);
@@ -178,8 +179,9 @@ impl FocusRing {
border.update(
size,
Rectangle::from_loc_and_size(gradient_area.loc - loc, gradient_area.size),
- gradient.from.into(),
- gradient.to.into(),
+ gradient.in_,
+ gradient.from,
+ gradient.to,
((gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_loc_and_size(full_rect.loc - loc, full_rect.size),
rounded_corner_border_width,
@@ -198,8 +200,9 @@ impl FocusRing {
gradient_area.loc - self.locations[0],
gradient_area.size,
),
- gradient.from.into(),
- gradient.to.into(),
+ gradient.in_,
+ gradient.from,
+ gradient.to,
((gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_loc_and_size(full_rect.loc - self.locations[0], full_rect.size),
rounded_corner_border_width,