26 lines
578 B
Rust
26 lines
578 B
Rust
use crate::point::Point;
|
|
use crate::transformer::Transformers;
|
|
use crate::worldstate::WorldState;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Translate
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
|
pub struct Translate {
|
|
pub x: f32,
|
|
pub y: f32,
|
|
}
|
|
|
|
impl Transformers for Translate {
|
|
fn apply(&self, point_list: &[Point], _ws: &WorldState) -> Vec<Point> {
|
|
point_list
|
|
.iter()
|
|
.map(|pt| Point {
|
|
x: pt.x + self.x,
|
|
y: pt.y + self.y,
|
|
..*pt
|
|
})
|
|
.collect()
|
|
}
|
|
}
|