123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import Foundation
- import AVFoundation
- extension CIRectangleFeature {
-
-
- func perimeter() -> CGFloat {
- return (topRight.x - topLeft.x) + (topRight.y - bottomRight.y) + (bottomRight.x - bottomLeft.x) + (topLeft.y - bottomLeft.y)
- }
-
-
-
-
-
-
-
- func isWithin(_ distance: CGFloat, ofRectangleFeature rectangleFeature: CIRectangleFeature) -> Bool {
-
- let topLeftRect = topLeft.surroundingSquare(withSize: distance)
- if !topLeftRect.contains(rectangleFeature.topLeft) {
- return false
- }
-
- let topRightRect = topRight.surroundingSquare(withSize: distance)
- if !topRightRect.contains(rectangleFeature.topRight) {
- return false
- }
-
- let bottomRightRect = bottomRight.surroundingSquare(withSize: distance)
- if !bottomRightRect.contains(rectangleFeature.bottomRight) {
- return false
- }
- let bottomLeftRect = bottomLeft.surroundingSquare(withSize: distance)
- if !bottomLeftRect.contains(rectangleFeature.bottomLeft) {
- return false
- }
-
- return true
- }
-
- override open var description: String {
- return "topLeft: \(topLeft), topRight: \(topRight), bottomRight: \(bottomRight), bottomLeft: \(bottomLeft)"
- }
-
- }
|