diff options
Diffstat (limited to 'src/bitmap.rs')
-rw-r--r-- | src/bitmap.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bitmap.rs b/src/bitmap.rs index ff41cb8..ffc0258 100644 --- a/src/bitmap.rs +++ b/src/bitmap.rs | |||
@@ -13,7 +13,7 @@ pub struct Pixmap<T> { | |||
13 | pub data: Vec<T>, | 13 | pub data: Vec<T>, |
14 | } | 14 | } |
15 | 15 | ||
16 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] | 16 | #[derive(Default, Copy, Clone, Debug, Hash, PartialEq, Eq)] |
17 | pub struct MapPoint { | 17 | pub struct MapPoint { |
18 | pub x: u32, | 18 | pub x: u32, |
19 | pub y: u32, | 19 | pub y: u32, |
@@ -111,6 +111,17 @@ impl MapPoint { | |||
111 | } | 111 | } |
112 | 112 | ||
113 | #[inline] | 113 | #[inline] |
114 | pub fn reduce(self, c: u32) -> MapPoint { | ||
115 | if c == 0 { | ||
116 | panic!("reduce MapPoint by zero") | ||
117 | } | ||
118 | MapPoint { | ||
119 | x: self.x / c, | ||
120 | y: self.y / c, | ||
121 | } | ||
122 | } | ||
123 | |||
124 | #[inline] | ||
114 | pub fn mirror_about(self, line: u32, axis: Axis) -> MapPoint { | 125 | pub fn mirror_about(self, line: u32, axis: Axis) -> MapPoint { |
115 | let MapPoint { x, y } = self; | 126 | let MapPoint { x, y } = self; |
116 | match axis { | 127 | match axis { |