24 lines
		
	
	
		
			441 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			441 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use crate::transformer::Transformers;
 | |
| use crate::point::Point;
 | |
| use serde::{Serialize,Deserialize};
 | |
| 
 | |
| /// 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]) -> Vec<Point> {	
 | |
| 	point_list.iter()
 | |
| 	    .map(| pt | {
 | |
| 		Point { x: pt.x + self.x,
 | |
| 			y: pt.y + self.y,
 | |
| 			..*pt
 | |
| 		}
 | |
| 	    }).collect()
 | |
|     }
 | |
| }
 |