feat: adding somme new transformation
* Rotate to rotate the image, !! Some point could be outside of the 0-4096 range on x and y !! you should parameter a center and an angle. All the point will move around the center. The angle is un degre. * Flip vertical: flip all the point verticaly. You should parameter an height where all point will flip * Flip horizontaly. You should parameter an X corrodinate where all point will flip around.
This commit is contained in:
parent
5f03d74080
commit
08e78b9a88
4 changed files with 101 additions and 0 deletions
28
src/transformer/flip_vertical.rs
Normal file
28
src/transformer/flip_vertical.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue