diff options
author | 2020-03-20 12:10:52 +0100 | |
---|---|---|
committer | 2020-03-20 12:10:52 +0100 | |
commit | f7ec679fec1b69c6dc5bc12d60627629f086bf22 (patch) | |
tree | 58ec4dd11e50f11ef85b972fee211930e7a0e7c0 /core/src/point.rs | |
parent | 93f5640a2dc06d8f1bf2b0d033d45c62f8985380 (diff) | |
parent | fb744a338c1b7566a3db9a3d24c03729b4858217 (diff) | |
download | iced-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.rs | 10 |
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 { |