summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-16 18:15:47 +0100
committerLaurenz <laurmaedje@gmail.com>2021-11-16 18:15:47 +0100
commit0cdf17216f47312f634d2dea8db237118ede72ce (patch)
tree1aa53f44f12da2f4473e72f166ecca380e72b4bb /src/geom
parent79638d4bbdc140a8dca0ccfdf70ffd607d5da251 (diff)
Abstraction for fr resolving
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/fr.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/geom/fr.rs b/src/geom/fr.rs
index c16a4d03..28d53d8f 100644
--- a/src/geom/fr.rs
+++ b/src/geom/fr.rs
@@ -34,6 +34,16 @@ impl Fractional {
pub fn abs(self) -> Self {
Self::new(self.get().abs())
}
+
+ /// Resolve this fractionals share in the remaining space.
+ pub fn resolve(self, total: Self, remaining: Length) -> Length {
+ let ratio = self / total;
+ if ratio.is_finite() && remaining.is_finite() {
+ ratio * remaining
+ } else {
+ Length::zero()
+ }
+ }
}
impl Debug for Fractional {