added canvas sizes

This commit is contained in:
Jon Janzen
2021-03-05 17:14:06 -07:00
parent 1fc84c7d1f
commit aa4e01d3f7
2 changed files with 144 additions and 2 deletions

View File

@@ -18,6 +18,27 @@ impl Color {
blue,
}
}
pub fn red(&self) -> f32 {
self.red
}
pub fn green(&self) -> f32 {
self.green
}
pub fn blue(&self) -> f32 {
self.blue
}
pub fn ppm_str(&self) -> String {
// need to scale 0 - 1 -> 0 - 255
let r = (self.red * 255.0) as u8;
let g = (self.green * 255.0) as u8;
let b = (self.blue * 255.0) as u8;
format!("{} {} {}", r, g, b)
}
}
impl PartialEq for Color {