split rectangle

This commit is contained in:
2024-08-28 16:22:20 +10:00
parent 503c48404c
commit f95be3f5f4
5 changed files with 84 additions and 84 deletions

View File

@ -0,0 +1,13 @@
struct Extent<T: AdditiveArithmetic>: Equatable {
var top: T, bottom: T, left: T, right: T
@inline(__always) static func == (lhs: Self, rhs: Self) -> Bool {
lhs.left == rhs.left && lhs.right == rhs.right && lhs.top == rhs.top && lhs.bottom == rhs.bottom
}
}
extension Extent where T: Comparable {
var size: Size<T> { .init(
right > left ? right - left : left - right,
bottom > top ? bottom - top : top - bottom) }
}