23 lines
493 B
Rust
23 lines
493 B
Rust
use crate::transformer::Transformers;
|
|
use crate::point::Point;
|
|
use serde::{Serialize,Deserialize};
|
|
|
|
/// Flip Horizontal
|
|
|
|
#[derive(Serialize,Deserialize,Debug,Clone,Copy)]
|
|
pub struct FlipHorizontal {
|
|
x: f32,
|
|
}
|
|
|
|
impl Transformers for FlipHorizontal {
|
|
fn apply(&self, point_list: &[Point]) -> Vec<Point> {
|
|
point_list.iter()
|
|
.map(| pt | {
|
|
let dx = pt.x - self.x;
|
|
Point { x: dx - 2. * dx,
|
|
..*pt
|
|
}
|
|
}).collect()
|
|
}
|
|
}
|