summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-14 08:10:50 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-14 08:10:50 +0100
commitf08cb4ad565799689d07bacc190fbe0436a63648 (patch)
tree1640c49cae49661d1c205755aa09592821698190 /core
parentdb441a64b18487f3f64bb4f99192548d7fac6893 (diff)
downloadiced-f08cb4ad565799689d07bacc190fbe0436a63648.tar.gz
iced-f08cb4ad565799689d07bacc190fbe0436a63648.tar.bz2
iced-f08cb4ad565799689d07bacc190fbe0436a63648.zip
Implement mouse-based pane resizing for `PaneGrid`
Diffstat (limited to 'core')
-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..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 {