1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Add bar charts and box plots (#863)

Changes:
* New `BarChart` and `BoxPlot` diagrams
* New `FloatOrd` trait for total ordering of float types
* Refactoring of existing plot items

Co-authored-by: niladic <git@nil.choron.cc>
This commit is contained in:
Jan Haller
2021-11-29 18:39:58 +01:00
committed by GitHub
parent 224d4d6d26
commit 1088d950e9
12 changed files with 1813 additions and 420 deletions

View File

@@ -309,6 +309,27 @@ impl Rect {
self.width() * self.height()
}
#[inline]
pub fn distance_sq_to_pos(&self, pos: Pos2) -> f32 {
let dx = if self.min.x > pos.x {
self.min.x - pos.x
} else if pos.x > self.max.x {
pos.x - self.max.x
} else {
0.0
};
let dy = if self.min.y > pos.y {
self.min.y - pos.y
} else if pos.y > self.max.y {
pos.y - self.max.y
} else {
0.0
};
dx * dx + dy * dy
}
#[inline(always)]
pub fn x_range(&self) -> RangeInclusive<f32> {
self.min.x..=self.max.x