mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Clamp colors to valid values when parsing config
The oklch color space often creates weird values when parsed by csscolorparser. clamping the output to values between 0 and 1 should fix inconsistent color handling on borders.
This commit is contained in:
committed by
Ivan Molodetskikh
parent
aa47223c19
commit
07080a0431
@@ -2677,7 +2677,10 @@ impl FromStr for Color {
|
||||
type Err = miette::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let color = csscolorparser::parse(s).into_diagnostic()?.to_array();
|
||||
let color = csscolorparser::parse(s)
|
||||
.into_diagnostic()?
|
||||
.clamp()
|
||||
.to_array();
|
||||
Ok(Self::from_array_unpremul(color))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user