1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Speed up fractal_clock painting (#152)

clip unwatchable line before drawing
This commit is contained in:
xue-blood
2021-02-06 23:59:46 +08:00
committed by GitHub
parent 26f966563a
commit ce14fa860b
3 changed files with 21 additions and 2 deletions

View File

@@ -91,6 +91,14 @@ impl Rect {
max: pos2(*x_range.end(), *y_range.end()),
}
}
pub fn from_two_pos(a: Pos2, b: Pos2) -> Self {
let (left, right) = if a.x > b.x { (b.x, a.x) } else { (a.x, b.x) };
let (top, bottom) = if a.y > b.y { (b.y, a.y) } else { (a.y, b.y) };
Rect {
min: pos2(left, top),
max: pos2(right, bottom),
}
}
/// Expand by this much in each direction, keeping the center
#[must_use]