diff options
author | 2020-05-05 00:05:47 +0200 | |
---|---|---|
committer | 2020-05-05 00:05:47 +0200 | |
commit | 7dc02a5e16a3143b7c3ba9270207e3ebda71d567 (patch) | |
tree | dd727f138641fbda008af8e7827369cc99420749 /core/src/point.rs | |
parent | 27aad74a32fd8ac2b12f9d32df8a3b61a3175457 (diff) | |
parent | 93c6be5eef577f0778b5787dac37351c035ed471 (diff) | |
download | iced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.tar.gz iced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.tar.bz2 iced-7dc02a5e16a3143b7c3ba9270207e3ebda71d567.zip |
Merge pull request #325 from hecrj/feature/canvas-interaction
Canvas interactivity and Game of Life example
Diffstat (limited to 'core/src/point.rs')
-rw-r--r-- | core/src/point.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/src/point.rs b/core/src/point.rs index 2b5ad154..3714aa2f 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -1,7 +1,7 @@ use crate::Vector; /// A 2D point. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct Point { /// The X coordinate. pub x: f32, @@ -67,3 +67,11 @@ impl std::ops::Sub<Vector> for Point { } } } + +impl std::ops::Sub<Point> for Point { + type Output = Vector; + + fn sub(self, point: Point) -> Vector { + Vector::new(self.x - point.x, self.y - point.y) + } +} |