bymsdfgen_core/math/
range.rs1#[derive(Debug, Clone, Copy, PartialEq)]
5pub struct Range {
6 pub lower: f64,
7 pub upper: f64,
8}
9
10impl Range {
11 #[inline]
13 pub const fn symmetric(width: f64) -> Self {
14 Range {
15 lower: -0.5 * width,
16 upper: 0.5 * width,
17 }
18 }
19
20 #[inline]
21 pub const fn new(lower: f64, upper: f64) -> Self {
22 Range { lower, upper }
23 }
24
25 #[inline]
26 pub fn width(self) -> f64 {
27 self.upper - self.lower
28 }
29}
30
31impl std::ops::Mul<f64> for Range {
32 type Output = Range;
33 #[inline]
34 fn mul(self, s: f64) -> Range {
35 Range::new(self.lower * s, self.upper * s)
36 }
37}
38
39impl std::ops::Div<f64> for Range {
40 type Output = Range;
41 #[inline]
42 fn div(self, s: f64) -> Range {
43 Range::new(self.lower / s, self.upper / s)
44 }
45}