forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB9d8f4f8Ivan Molodetskikh1 month ago2997 commits

gradient_oklab.rs54 lines, 1.6 KiBHistoryRawDownload
1use niri::render_helpers::border::BorderRenderElement;
2use niri_config::{
3 Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
4};
5use smithay::backend::renderer::element::RenderElement;
6use smithay::backend::renderer::gles::GlesRenderer;
7use smithay::utils::{Physical, Point, Rectangle, Size};
8
9use super::{Args, TestCase};
10
11pub struct GradientOklab {
12 gradient_format: GradientInterpolation,
13}
14
15impl GradientOklab {
16 pub fn new(_args: Args) -> Self {
17 Self {
18 gradient_format: GradientInterpolation {
19 color_space: GradientColorSpace::Oklab,
20 hue_interpolation: HueInterpolation::Shorter,
21 },
22 }
23 }
24}
25
26impl TestCase for GradientOklab {
27 fn render(
28 &mut self,
29 _renderer: &mut GlesRenderer,
30 size: Size<i32, Physical>,
31 ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
32 let (a, b) = (size.w / 6, size.h / 3);
33 let size = (size.w - a * 2, size.h - b * 2);
34 let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
35
36 [BorderRenderElement::new(
37 area.size,
38 Rectangle::from_size(area.size),
39 self.gradient_format,
40 Color::new_unpremul(1., 0., 0., 1.),
41 Color::new_unpremul(0., 1., 0., 1.),
42 0.,
43 Rectangle::from_size(area.size),
44 0.,
45 CornerRadius::default(),
46 1.,
47 1.,
48 )
49 .with_location(area.loc)]
50 .into_iter()
51 .map(|elem| Box::new(elem) as _)
52 .collect()
53 }
54}