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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user