summaryrefslogtreecommitdiffstats
path: root/svgbob/src/loc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'svgbob/src/loc.rs')
-rw-r--r--svgbob/src/loc.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/svgbob/src/loc.rs b/svgbob/src/loc.rs
index fa83d11..27f88e6 100644
--- a/svgbob/src/loc.rs
+++ b/svgbob/src/loc.rs
@@ -4,6 +4,7 @@ use location::Direction::{Top,Bottom,Left,Right,TopLeft,TopRight,BottomLeft,Bott
/// Location of Block relative to the Grid
/// This the equivalent to the cell cation in the grid
+/// 0,0 is the top left most
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq)]
pub struct Loc {
pub x: i32,
@@ -65,6 +66,13 @@ impl Loc {
y: self.y - 1,
}
}
+ pub fn in_top(&self, n: i32) -> Loc {
+ Loc {
+ x: self.x,
+ y: self.y - n,
+ }
+ }
+
pub fn left(&self) -> Loc {
Loc {
x: self.x - 1,
@@ -83,6 +91,12 @@ impl Loc {
y: self.y + 1,
}
}
+ pub fn in_bottom(&self, n: i32) -> Loc {
+ Loc {
+ x: self.x,
+ y: self.y + n,
+ }
+ }
pub fn right(&self) -> Loc {
Loc {
x: self.x + 1,