improvements to point, color

This commit is contained in:
Brandon Thomas
2021-01-14 00:34:56 -05:00
parent 03b167d377
commit 201c0953ed
3 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -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,
}
}
+2 -2
View File
@@ -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);
+6
View File
@@ -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)
}
}