From 201c0953eda775133f837228b580f301fe4a4ebc Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 14 Jan 2021 00:34:56 -0500 Subject: [PATCH] improvements to point, color --- src/color.rs | 4 ++-- src/main.rs | 4 ++-- src/point.rs | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/color.rs b/src/color.rs index 0d0c158..eaf1cd8 100644 --- a/src/color.rs +++ b/src/color.rs @@ -35,9 +35,9 @@ impl Color { match &self { Color::Black => 0.0f32, Color::White => 1.0f32, - Color::Red => 1.0f32, + Color::Red => 0.0f32, Color::Green => 0.0f32, - Color::Blue => 0.0f32, + Color::Blue => 1.0f32, Color::Custom {r, g, b} => *b, } } diff --git a/src/main.rs b/src/main.rs index 8bea6e6..f3b2033 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,9 @@ fn main() { let mut messaging_state = MessagingState::Sending; loop { - let point = Point::at_random_range(-1000.0f32, 1000.0f32, Color::White); + let point = Point::at_random_range(-1.0f32, 1.0f32, Color::Blue); let bytes = point.to_bytes(); - println!("Location: {}", point.location_string()); + println!("Point : {}", point.debug_string()); if reconnect { socket = reconnect_socket(&context, socket, SOCKET_ADDRESS); diff --git a/src/point.rs b/src/point.rs index ef8ebb7..5f44604 100644 --- a/src/point.rs +++ b/src/point.rs @@ -67,4 +67,10 @@ impl Point { pub fn location_string(&self) -> String { format!("{}, {}, {}", self.x, self.y, self.z) } + + pub fn debug_string(&self) -> String { + format!("(location: {}, {}, {}); (color: {}, {}, {}, alpha: {})", + self.x, self.y, self.z, + self.r, self.g, self.b, self.a) + } } \ No newline at end of file