wipe/src/vec.rs

20 lines
520 B
Rust
Raw Normal View History

2022-04-03 10:30:36 +00:00
/// A vector with a x and y axis.
2022-04-02 15:23:19 +00:00
#[derive(Copy, Clone)]
pub struct Vector {
pub x: f32,
pub y: f32
}
impl Vector {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
2022-04-03 10:30:36 +00:00
/// Creates a vector with the on screen coordinates based on the terminal coordinates.
/// # Arguments
/// * `x`: The x axis of the terminal character.
/// * `y`: The y axis of the terminal character.
2022-04-02 15:23:19 +00:00
pub fn from_terminal(x: usize, y: usize) -> Self {
Vector::new(x as f32, y as f32 * 2.0)
}
}