From 3db823ef6492dfe064ef53c9620a8c08af6ff58e Mon Sep 17 00:00:00 2001 From: Isabelle L Date: Sat, 13 Jun 2020 16:13:19 -0500 Subject: [PATCH] moved color consts into color impl --- src/color.rs | 8 +++++--- src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/color.rs b/src/color.rs index 8cec646..e2be827 100644 --- a/src/color.rs +++ b/src/color.rs @@ -15,7 +15,9 @@ impl Color { let (r, g, b) = (self.r as u32, self.g as u32, self.b as u32); (r << 16) | (g << 8) | b } -} -pub const BLACK: Color = Color { r: 0x00, g: 0x00, b: 0x00 }; -pub const WHITE: Color = Color { r: 0xff, g: 0xff, b: 0xff }; + /// white color + pub const WHITE: Color = Color { r: 0xff, g: 0xff, b: 0xff }; + /// black color + pub const BLACK: Color = Color { r: 0x00, g: 0x00, b: 0x00 }; +} diff --git a/src/lib.rs b/src/lib.rs index 177f1b2..72cd7b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ impl Context { /// clears the pixel buffer pub fn clear(&mut self, color: Option) { - let color = color.unwrap_or(color::BLACK); + let color = color.unwrap_or(Color::BLACK); self.pixel_buffer.as_mut_ref().iter_mut().for_each(|pixel| *pixel = color.as_u32()); }