29 lines
566 B
Rust
29 lines
566 B
Rust
use crate::transformer::Transformers;
|
|
use crate::point::Point;
|
|
use serde::{Serialize,Deserialize};
|
|
|
|
/// Flip Vertical
|
|
|
|
#[derive(Serialize,Deserialize,Debug,Clone,Copy)]
|
|
pub struct FlipVertical {
|
|
y: f32,
|
|
}
|
|
|
|
impl FlipVertical {
|
|
pub fn new(y: f32) -> Self {
|
|
Self {y}
|
|
}
|
|
}
|
|
|
|
impl Transformers for FlipVertical {
|
|
fn apply(&self, point_list: &[Point]) -> Vec<Point> {
|
|
point_list.iter()
|
|
.map(| pt | {
|
|
let dy = pt.y - self.y;
|
|
Point { y: dy - 2. * dy,
|
|
..*pt
|
|
}
|
|
}).collect()
|
|
}
|
|
}
|