1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00

WIP: Working clip rects for glium

This commit is contained in:
Emil Ernerfeldt
2020-04-21 00:17:02 +02:00
parent 2f02446f6f
commit 46f123eeb6
4 changed files with 59 additions and 22 deletions

View File

@@ -63,6 +63,10 @@ impl Vec2 {
vec2(self.x.ceil(), self.y.ceil())
}
pub fn is_finite(&self) -> bool {
self.x.is_finite() && self.y.is_finite()
}
pub fn min(self, other: Vec2) -> Self {
vec2(self.x.min(other.x), self.y.min(other.y))
}
@@ -195,6 +199,10 @@ impl Pos2 {
pub fn ceil(self) -> Self {
pos2(self.x.ceil(), self.y.ceil())
}
pub fn is_finite(&self) -> bool {
self.x.is_finite() && self.y.is_finite()
}
}
impl std::ops::AddAssign<Vec2> for Pos2 {
@@ -342,6 +350,14 @@ impl Rect {
self.max.y - self.min.y
}
pub fn is_empty(&self) -> bool {
self.max.x < self.min.x || self.max.y < self.min.y
}
pub fn is_finite(&self) -> bool {
self.min.is_finite() && self.max.is_finite()
}
// Convenience functions (assumes origin is towards left top):
pub fn left_top(&self) -> Pos2 {