mirror of
https://github.com/storytold/point-generator.git
synced 2026-10-20 07:44:46 +00:00
improvements to point, color
This commit is contained in:
+2
-2
@@ -35,9 +35,9 @@ impl Color {
|
|||||||
match &self {
|
match &self {
|
||||||
Color::Black => 0.0f32,
|
Color::Black => 0.0f32,
|
||||||
Color::White => 1.0f32,
|
Color::White => 1.0f32,
|
||||||
Color::Red => 1.0f32,
|
Color::Red => 0.0f32,
|
||||||
Color::Green => 0.0f32,
|
Color::Green => 0.0f32,
|
||||||
Color::Blue => 0.0f32,
|
Color::Blue => 1.0f32,
|
||||||
Color::Custom {r, g, b} => *b,
|
Color::Custom {r, g, b} => *b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -31,9 +31,9 @@ fn main() {
|
|||||||
let mut messaging_state = MessagingState::Sending;
|
let mut messaging_state = MessagingState::Sending;
|
||||||
|
|
||||||
loop {
|
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();
|
let bytes = point.to_bytes();
|
||||||
println!("Location: {}", point.location_string());
|
println!("Point : {}", point.debug_string());
|
||||||
|
|
||||||
if reconnect {
|
if reconnect {
|
||||||
socket = reconnect_socket(&context, socket, SOCKET_ADDRESS);
|
socket = reconnect_socket(&context, socket, SOCKET_ADDRESS);
|
||||||
|
|||||||
@@ -67,4 +67,10 @@ impl Point {
|
|||||||
pub fn location_string(&self) -> String {
|
pub fn location_string(&self) -> String {
|
||||||
format!("{}, {}, {}", self.x, self.y, self.z)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user