-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implemented some CGRect's missing APIs #1160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix for 2 bugs: 1. ```swift CGRect(x: 0, y: 0, width: -5, height: -5) == CGRect(x: -5, y: -5, width: 5, height: 5) // used to return false // should standardize before comparison first ``` 2. ```swift let a = CGRect(x: CGFloat.infinity, y: 1, width: 2, height: 3) let b = CGRect(x: 1, y: CGFloat.infinity, width: 2, height: 3) a == b // used to return false // should return true if both `a` and `b` have any origin's value set to +∞ ```
@swift-ci please test |
@parkera it looks like that this PR is still awaiting your review. We too ran into the issue of these missing CGRect APIs and ended up implementing them in our internal fork. However we'd really like to move off our internal fork ASAP as it's a pain to keep that up to date. So the sooner this PR could be merged into the official repo the better. Thanks. |
@alblue done 👌 |
@swift-ci please test |
@phausler can you opine on the CGRect changes, please? |
looks pretty reasonable to me, they fit all of the expected behaviors on Darwin. |
@swift-ci please test and merge |
Calculated Geometric Properties
CGRect.height: CGFloat { get }
CGRect.width: CGFloat { get }
CGRect.minX: CGFloat { get }
CGRect.midX: CGFloat { get }
CGRect.maxX: CGFloat { get }
CGRect.minY: CGFloat { get }
CGRect.midY: CGFloat { get }
CGRect.maxY: CGFloat { get }
Creating Derived Rectangles
CGRect.standardized: CGRect { get }
CGRect.integral: CGRect { get }
CGRect.insetBy(dx: CGFloat, dy: CGFloat) -> CGRect
CGRect.offsetBy(dx: CGFloat, dy: CGFloat) -> CGRect
CGRect.union(_ r2: CGRect) -> CGRect
CGRect.intersection(_ r2: CGRect) -> CGRect
CGRect.divided(atDistance: CGFloat, from fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect)
Checking Characteristics
CGRect.intersects(_ rect2: CGRect) -> Bool
CGRect.contains(_ point: CGPoint) -> Bool
CGRect.contains(_ rect2: CGRect) -> Bool
CGRect.isEmpty: Bool { get }
CGRect.isInfinite: Bool { get }
CGRect.isNull: Bool { get }
📝 Also fixed 2 bugs in
CGRect : Equatable