diff options
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/fr.rs | 10 |
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 { |
