diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-10-28 16:43:38 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-10-28 16:43:38 +0200 |
| commit | 95e9134a3c7d7a14d8c8928413fdffc665671895 (patch) | |
| tree | 822b5f6c2d23aba33cfe4d199405e493e37c3d70 /src/geom/point.rs | |
| parent | 66030ae5d73d85a0463562230b87f8ec7554c746 (diff) | |
Refactor `geom` module
Diffstat (limited to 'src/geom/point.rs')
| -rw-r--r-- | src/geom/point.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/geom/point.rs b/src/geom/point.rs index 7f67d353..34d3dcd8 100644 --- a/src/geom/point.rs +++ b/src/geom/point.rs @@ -4,35 +4,35 @@ use super::*; #[derive(Default, Copy, Clone, Eq, PartialEq, Hash)] pub struct Point { /// The x coordinate. - pub x: Length, + pub x: Abs, /// The y coordinate. - pub y: Length, + pub y: Abs, } impl Point { /// The origin point. pub const fn zero() -> Self { - Self { x: Length::zero(), y: Length::zero() } + Self { x: Abs::zero(), y: Abs::zero() } } /// Create a new point from x and y coordinates. - pub const fn new(x: Length, y: Length) -> Self { + pub const fn new(x: Abs, y: Abs) -> Self { Self { x, y } } /// Create an instance with two equal components. - pub const fn splat(value: Length) -> Self { + pub const fn splat(value: Abs) -> Self { Self { x: value, y: value } } /// Create a new point with y set to zero. - pub const fn with_x(x: Length) -> Self { - Self { x, y: Length::zero() } + pub const fn with_x(x: Abs) -> Self { + Self { x, y: Abs::zero() } } /// Create a new point with x set to zero. - pub const fn with_y(y: Length) -> Self { - Self { x: Length::zero(), y } + pub const fn with_y(y: Abs) -> Self { + Self { x: Abs::zero(), y } } /// Transform the point with the given transformation. @@ -54,20 +54,20 @@ impl Numeric for Point { } } -impl Get<SpecAxis> for Point { - type Component = Length; +impl Get<Axis> for Point { + type Component = Abs; - fn get(self, axis: SpecAxis) -> Length { + fn get(self, axis: Axis) -> Abs { match axis { - SpecAxis::Horizontal => self.x, - SpecAxis::Vertical => self.y, + Axis::X => self.x, + Axis::Y => self.y, } } - fn get_mut(&mut self, axis: SpecAxis) -> &mut Length { + fn get_mut(&mut self, axis: Axis) -> &mut Abs { match axis { - SpecAxis::Horizontal => &mut self.x, - SpecAxis::Vertical => &mut self.y, + Axis::X => &mut self.x, + Axis::Y => &mut self.y, } } } |
