1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::drawing::backend::BackendCoord;
mod datetime;
mod numeric;
mod ranged;
pub use datetime::{RangedDate, RangedDateTime};
pub use numeric::{
RangedCoordf32, RangedCoordf64, RangedCoordi32, RangedCoordi64, RangedCoordu32, RangedCoordu64,
};
pub use ranged::{DescreteRanged, MeshLine, Ranged, RangedCoord};
pub trait CoordTranslate {
type From;
fn translate(&self, from: &Self::From) -> BackendCoord;
}
#[derive(Debug, Clone)]
pub struct Shift(pub BackendCoord);
impl CoordTranslate for Shift {
type From = BackendCoord;
fn translate(&self, from: &Self::From) -> BackendCoord {
return (from.0 + (self.0).0, from.1 + (self.0).1);
}
}
pub struct ShiftAndTrans<T: CoordTranslate>(Shift, T);
impl<T: CoordTranslate> CoordTranslate for ShiftAndTrans<T> {
type From = T::From;
fn translate(&self, from: &Self::From) -> BackendCoord {
let temp = self.1.translate(from);
return self.0.translate(&temp);
}
}