fix bug in generating complement for colors with hue under 180deg
This commit is contained in:
parent
790b0685cb
commit
a7eb78d249
@ -465,12 +465,8 @@ impl Color {
|
||||
|
||||
pub fn complement(&self) -> Self {
|
||||
let (hue, saturation, luminance, alpha) = self.as_hsla();
|
||||
let hue = if hue > Number::from(180) {
|
||||
Number::from(360) - hue
|
||||
} else {
|
||||
hue + Number::from(180)
|
||||
};
|
||||
Color::from_hsla(hue, saturation, luminance, alpha)
|
||||
|
||||
Color::from_hsla(hue + Number::from(180), saturation, luminance, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,16 +387,21 @@ test!(
|
||||
"a {\n color: gray;\n}\n"
|
||||
);
|
||||
test!(grayscale_number, "a {\n color: grayscale(15%);\n}\n");
|
||||
// handle special functions better!
|
||||
// test!(
|
||||
// grayscale_number_casing,
|
||||
// "a {\n color: grAyscaLe(15%);\n}\n"
|
||||
// );
|
||||
test!(
|
||||
#[ignore]
|
||||
grayscale_number_casing,
|
||||
"a {\n color: grAyscaLe(15%);\n}\n"
|
||||
);
|
||||
test!(
|
||||
complement,
|
||||
"a {\n color: complement(red);\n}\n",
|
||||
"a {\n color: aqua;\n}\n"
|
||||
);
|
||||
test!(
|
||||
complement_hue_under_180,
|
||||
"a {\n color: complement(#abcdef);\n}\n",
|
||||
"a {\n color: #efcdab;\n}\n"
|
||||
);
|
||||
test!(
|
||||
mix_no_weight,
|
||||
"a {\n color: mix(#f00, #00f);\n}\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user