builtin fns red, green, and blue round their output

This commit is contained in:
Connor Skees 2020-07-04 18:46:23 -04:00
parent 3cde25959b
commit 65f93ad6d5
2 changed files with 23 additions and 3 deletions

View File

@ -151,15 +151,15 @@ impl Color {
} }
pub fn red(&self) -> Number { pub fn red(&self) -> Number {
self.rgba.red.clone() self.rgba.red.clone().round()
} }
pub fn blue(&self) -> Number { pub fn blue(&self) -> Number {
self.rgba.blue.clone() self.rgba.blue.clone().round()
} }
pub fn green(&self) -> Number { pub fn green(&self) -> Number {
self.rgba.green.clone() self.rgba.green.clone().round()
} }
/// Mix two colors together with weight /// Mix two colors together with weight

View File

@ -603,3 +603,23 @@ test!(
"a {\n color: #00000000f00;\n}\n", "a {\n color: #00000000f00;\n}\n",
"a {\n color: #00000000 f00;\n}\n" "a {\n color: #00000000 f00;\n}\n"
); );
test!(
all_three_rgb_channels_have_decimal,
"a {\n color: rgba(1.5, 1.5, 1.5, 1);\n}\n",
"a {\n color: #020202;\n}\n"
);
test!(
builtin_fn_red_rounds_channel,
"a {\n color: red(rgba(1.5, 1.5, 1.5, 1));\n}\n",
"a {\n color: 2;\n}\n"
);
test!(
builtin_fn_green_rounds_channel,
"a {\n color: green(rgba(1.5, 1.5, 1.5, 1));\n}\n",
"a {\n color: 2;\n}\n"
);
test!(
builtin_fn_blue_rounds_channel,
"a {\n color: blue(rgba(1.5, 1.5, 1.5, 1));\n}\n",
"a {\n color: 2;\n}\n"
);