diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-12 18:58:39 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-12 19:57:28 +0100 |
| commit | 3ffa7393f0632d9ee5dd9c821685a1a033d5c0ab (patch) | |
| tree | af09b0683352c4028436a2e5251dce54cf41d4aa /src/geom/point.rs | |
| parent | f4856c18b9cf3f6952276cc61b557aebeb2fa651 (diff) | |
Make all nodes block-level
Diffstat (limited to 'src/geom/point.rs')
| -rw-r--r-- | src/geom/point.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/geom/point.rs b/src/geom/point.rs index 34d3dcd8..ce3a6ff2 100644 --- a/src/geom/point.rs +++ b/src/geom/point.rs @@ -35,6 +35,16 @@ impl Point { Self { x: Abs::zero(), y } } + /// The component-wise minimum of this and another point. + pub fn min(self, other: Self) -> Self { + Self { x: self.x.min(other.x), y: self.y.min(other.y) } + } + + /// The component-wise minimum of this and another point. + pub fn max(self, other: Self) -> Self { + Self { x: self.x.max(other.x), y: self.y.max(other.y) } + } + /// Transform the point with the given transformation. pub fn transform(self, ts: Transform) -> Self { Self::new( @@ -42,6 +52,11 @@ impl Point { ts.ky.of(self.x) + ts.sy.of(self.y) + ts.ty, ) } + + /// Convert to a size. + pub fn to_size(self) -> Size { + Size::new(self.x, self.y) + } } impl Numeric for Point { |
