Expand bounds for 'contains' to account for points on the rightmost and bottommost bounds.

This commit is contained in:
Jonathan Cardasis 2019-04-12 00:22:56 -04:00
parent 65eab137b3
commit 927a4d8834

View File

@ -56,7 +56,7 @@ public class ColorWheelView: UIView {
the point does not exist within the bounds of the color wheel. the point does not exist within the bounds of the color wheel.
*/ */
public func pixelColor(at point: CGPoint) -> UIColor? { public func pixelColor(at point: CGPoint) -> UIColor? {
guard bounds.contains(point) else { return nil } guard bounds.offsetBy(dx: 1, dy: 1).contains(point) else { return nil }
let distanceFromCenter: CGFloat = hypot(center.x - point.x, center.y - point.y) let distanceFromCenter: CGFloat = hypot(center.x - point.x, center.y - point.y)
let pointExistsInRadius: Bool = distanceFromCenter <= radius let pointExistsInRadius: Bool = distanceFromCenter <= radius