added tests for alpha in oklch longer

This commit is contained in:
K's Thinkpad 2024-07-12 14:19:53 +02:00
parent 4c80ab922f
commit f223b6d2a7
3 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,51 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{CornerRadius, GradientInterpolation, HueInterpolation, GradientColorSpace};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use super::TestCase;
pub struct GradientOklchAlpha {
gradient_format: GradientInterpolation,
}
impl GradientOklchAlpha {
pub fn new(_size: Size<i32, Logical>) -> Self {
Self {
gradient_format: GradientInterpolation{
color_space: GradientColorSpace::Oklch,
hue_interpol: HueInterpolation::Longer
}
}
}
}
impl TestCase for GradientOklchAlpha {
fn render(
&mut self,
_renderer: &mut GlesRenderer,
size: Size<i32, Physical>,
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
self.gradient_format,
[1., 0., 0., 1.],
[0., 1., 0., 0.],
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
0.,
CornerRadius::default(),
1.,
)
.with_location(area.loc)]
.into_iter()
.map(|elem| Box::new(elem) as _)
.collect()
}
}

View File

@ -13,6 +13,7 @@ pub mod gradient_oklch_shorter;
pub mod gradient_oklch_longer;
pub mod gradient_oklch_increasing;
pub mod gradient_oklch_decreasing;
pub mod gradient_oklch_alpha;
pub mod layout;
pub mod tile;
pub mod window;

View File

@ -5,6 +5,7 @@ use std::env;
use std::sync::atomic::Ordering;
use adw::prelude::{AdwApplicationWindowExt, NavigationPageExt};
use cases::gradient_oklch_alpha::GradientOklchAlpha;
use cases::tile::Tile;
use cases::window::Window;
use gtk::prelude::{
@ -126,6 +127,7 @@ fn build_ui(app: &adw::Application) {
s.add(GradientOklchLonger::new, "Gradient - Oklch Longer");
s.add(GradientOklchIncreasing::new, "Gradient - Oklch Increasing");
s.add(GradientOklchDecreasing::new, "Gradient - Oklch Decreasing");
s.add(GradientOklchAlpha::new, "Gradient - Alpha");
let content_headerbar = adw::HeaderBar::new();