From f08cb4ad565799689d07bacc190fbe0436a63648 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 14 Mar 2020 08:10:50 +0100 Subject: Implement mouse-based pane resizing for `PaneGrid` --- core/src/point.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core/src') diff --git a/core/src/point.rs b/core/src/point.rs index b55f5099..b855cd91 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; + + f32::sqrt(a * a + b * b) + } } impl From<[f32; 2]> for Point { -- cgit