1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Shape refactor (#705)

* More introspection stats about vertices/indices etc

* more serde derive

* #[inline] to Shape constructors

* Introduce RectShape

* Introduce CircleShape

* Introduce PathShape

* More serde derive

* impl Copy for RectShape and CircleShape

* Simplify some code

* More serde derive

* Add helpers for appending more input or output

* Serde derives for RawInput

* Rename Fonts::from_definitions to Fonts::new

* Add Output::take

* refactor EguiGlium slightly

* Derive PartialEq for RawInput

* Improve egui::util::History interface

* tweaks

* Improve History filter: add minimum length

* Calculate galley bounding rect

* tessellator: cull line segments and paths

* tessellator: cull meshes

* Fix bug in History bandwidth estimator
This commit is contained in:
Emil Ernerfeldt
2021-09-20 21:36:56 +02:00
committed by GitHub
parent 93c2fde1fc
commit e7cfda4941
36 changed files with 578 additions and 313 deletions

View File

@@ -88,6 +88,15 @@ impl Rect {
}
}
/// Bounding-box around the points
pub fn from_points(points: &[Pos2]) -> Self {
let mut rect = Rect::NOTHING;
for &p in points {
rect.extend_with(p);
}
rect
}
/// A `Rect` that contains every point to the right of the given X coordinate.
#[inline]
pub fn everything_right_of(left_x: f32) -> Self {
@@ -165,15 +174,6 @@ impl Rect {
)
}
/// The intersection of two `Rect`, i.e. the area covered by both.
#[must_use]
pub fn intersect(self, other: Rect) -> Self {
Self {
min: self.min.max(other.min),
max: self.max.min(other.max),
}
}
#[must_use]
#[inline]
pub fn intersects(self, other: Rect) -> bool {
@@ -236,7 +236,10 @@ impl Rect {
self.max.y = self.max.y.max(y);
}
/// The union of two bounding rectangle, i.e. the minimum `Rect`
/// that contains both input rectangles.
#[inline(always)]
#[must_use]
pub fn union(self, other: Rect) -> Rect {
Rect {
min: self.min.min(other.min),
@@ -244,6 +247,16 @@ impl Rect {
}
}
/// The intersection of two `Rect`, i.e. the area covered by both.
#[inline]
#[must_use]
pub fn intersect(self, other: Rect) -> Self {
Self {
min: self.min.max(other.min),
max: self.max.min(other.max),
}
}
#[inline(always)]
pub fn center(&self) -> Pos2 {
Pos2 {