Expand description
A two-dimensional vector representing a point.
Examples
let point = point!(10, 0);
// A point can be moved with an offset
let moved_point = point + offset!(20, 5);
assert_eq!(moved_point, point!(30, 5));
// A tuple offset can also be used
let moved_point = point + (20, 5);
assert_eq!(moved_point, point!(30, 5));
Implementations
sourceimpl<T> Point2D<T>
impl<T> Point2D<T>
sourcepub fn offset<P: ToPoint2D<T>>(self, point: P) -> Offset2D<T> where
T: Sub<Output = T>,
pub fn offset<P: ToPoint2D<T>>(self, point: P) -> Offset2D<T> where
T: Sub<Output = T>,
Returns the offset between self
and point
.
Order matters here, so if you are trying to get the offset
needed for point A to get to point B, you would do a.offset(b)
.
Examples
let a = point!(10, 40);
let b = point!(5, 60);
assert_eq!(a.offset(b), offset!(-5, 20));