mirror of
https://github.com/YaLTeR/niri.git
synced 2024-08-17 16:20:23 +03:00
fixed the problem with 0 alpha would cause information loss
This commit is contained in:
parent
f223b6d2a7
commit
bb300b6290
@ -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,
|
||||
},
|
||||
|
@ -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