mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 20:37:25 +03:00
Compare commits
6 Commits
b65bee848f
...
ff20757e7d
Author | SHA1 | Date | |
---|---|---|---|
|
ff20757e7d | ||
|
a89c800c7f | ||
|
bb300b6290 | ||
|
a5a34934df | ||
|
f223b6d2a7 | ||
|
4c80ab922f |
11
Cargo.toml
11
Cargo.toml
@ -141,3 +141,14 @@ assets = [
|
||||
[package.metadata.generate-rpm.requires]
|
||||
alacritty = "*"
|
||||
fuzzel = "*"
|
||||
|
||||
[package.metadata.deb]
|
||||
depends = "alacritty, fuzzel"
|
||||
assets = [
|
||||
["target/release/niri", "usr/bin/", "755"],
|
||||
["resources/niri-session", "usr/bin/", "755"],
|
||||
["resources/niri.desktop", "/usr/share/wayland-sessions/", "644"],
|
||||
["resources/niri-portals.conf", "/usr/share/xdg-desktop-portal/", "644"],
|
||||
["resources/niri.service", "/usr/lib/systemd/user/", "644"],
|
||||
["resources/niri-shutdown.target", "/usr/lib/systemd/user/", "644"],
|
||||
]
|
||||
|
@ -529,7 +529,8 @@ impl Color {
|
||||
impl From<Color> for [f32; 4] {
|
||||
fn from(c: Color) -> Self {
|
||||
let [r, g, b, a] = [c.r, c.g, c.b, c.a].map(|x| x as f32 / 255.);
|
||||
[r * a, g * a, b * a, a]
|
||||
//[r * a, g * a, b * a, a]
|
||||
[r, g, b, a]
|
||||
}
|
||||
}
|
||||
|
||||
@ -2853,6 +2854,10 @@ mod tests {
|
||||
to: Color::new(0, 128, 255, 255),
|
||||
angle: 180,
|
||||
relative_to: GradientRelativeTo::WorkspaceView,
|
||||
in_ : GradientInterpolation {
|
||||
color_space: GradientColorSpace::Srgb,
|
||||
hue_interpol: HueInterpolation::Shorter,
|
||||
}
|
||||
}),
|
||||
inactive_gradient: None,
|
||||
},
|
||||
|
51
niri-visual-tests/src/cases/gradient_oklch_alpha.rs
Normal file
51
niri-visual-tests/src/cases/gradient_oklch_alpha.rs
Normal 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()
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -98,16 +98,15 @@ vec3 oklab_to_linear(vec3 color){
|
||||
|
||||
vec4 color_mix(vec4 color1, vec4 color2, float color_ratio) {
|
||||
// srgb
|
||||
|
||||
vec4 color_out;
|
||||
|
||||
if (colorspace == 0.0) {
|
||||
return mix(color1, color2, color_ratio);
|
||||
color_out = mix(color1, color2, color_ratio);
|
||||
color_out.rgb = color_out.rgb * color_out.a;
|
||||
return color_out;
|
||||
}
|
||||
|
||||
vec4 color_out;
|
||||
|
||||
color1.rgb /= color1.a != 0.0 ? color1.a : 1.0;
|
||||
color2.rgb /= color2.a != 0.0 ? color2.a : 1.0;
|
||||
|
||||
color1.rgb = vec3(
|
||||
srgb_to_linear(color1.r),
|
||||
srgb_to_linear(color1.g),
|
||||
|
Loading…
Reference in New Issue
Block a user