diff options
Diffstat (limited to 'svgbob/src/point.rs')
-rw-r--r-- | svgbob/src/point.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/svgbob/src/point.rs b/svgbob/src/point.rs index 395c92e..26a67ea 100644 --- a/svgbob/src/point.rs +++ b/svgbob/src/point.rs @@ -1,3 +1,4 @@ +use crate::buffer::CellGrid; use crate::util; use nalgebra::{Point2, Vector2}; use std::{ @@ -53,6 +54,25 @@ impl Point { }; Point::new(x, y) } + + /// adjust x value by units specified + pub fn adjust_x(&self, units: f32) -> Self { + let t = units * CellGrid::unit_x(); + Self::new(self.x + t, self.y) + } + + /// adjust y value by units specified + pub fn adjust_y(&self, units: f32) -> Self { + let t = units * CellGrid::unit_y(); + Self::new(self.x, self.y + t) + } + + /// adjust both x and y value by units specified + pub fn adjust(&self, units: f32) -> Self { + let t = units * CellGrid::unit_x(); + let u = units * CellGrid::unit_y(); + Self::new(self.x + t, self.y + u) + } } impl From<Point2<f32>> for Point { |