Skip to content

Commit 3716158

Browse files
committed
Fix color serialization.
1 parent 5b8e47c commit 3716158

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/color.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ pub struct RGBA {
2121
impl fmt::Show for RGBA {
2222
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2323
if self.alpha == 1f32 {
24-
write!(f, "rgb({}, {}, {}", self.red, self.green, self.blue)
24+
write!(f, "rgb({}, {}, {})", (self.red * 255.).round(), (self.green * 255.).round(),
25+
(self.blue * 255.).round())
2526
} else {
26-
write!(f, "rgba({} {} {} {})", self.red, self.green, self.blue, self.alpha)
27+
write!(f, "rgba({}, {}, {}, {})", (self.red * 255.).round(), (self.green * 255.).round(),
28+
(self.blue * 255.).round(), self.alpha)
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)