summaryrefslogtreecommitdiffstats
path: root/core/src/point.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-03-20 12:10:52 +0100
committerLibravatar GitHub <noreply@github.com>2020-03-20 12:10:52 +0100
commitf7ec679fec1b69c6dc5bc12d60627629f086bf22 (patch)
tree58ec4dd11e50f11ef85b972fee211930e7a0e7c0 /core/src/point.rs
parent93f5640a2dc06d8f1bf2b0d033d45c62f8985380 (diff)
parentfb744a338c1b7566a3db9a3d24c03729b4858217 (diff)
downloadiced-f7ec679fec1b69c6dc5bc12d60627629f086bf22.tar.gz
iced-f7ec679fec1b69c6dc5bc12d60627629f086bf22.tar.bz2
iced-f7ec679fec1b69c6dc5bc12d60627629f086bf22.zip
Merge pull request #224 from hecrj/feature/panes-widget
Pane grid widget
Diffstat (limited to 'core/src/point.rs')
-rw-r--r--core/src/point.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/point.rs b/core/src/point.rs
index b55f5099..43ee2143 100644
--- a/core/src/point.rs
+++ b/core/src/point.rs
@@ -22,6 +22,16 @@ impl Point {
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
+
+ /// Computes the distance to another [`Point`].
+ ///
+ /// [`Point`]: struct.Point.html
+ pub fn distance(&self, to: Point) -> f32 {
+ let a = self.x - to.x;
+ let b = self.y - to.y;
+
+ a.hypot(b)
+ }
}
impl From<[f32; 2]> for Point {