From ec071fff26c64fe79259e02bad335a250ad352c4 Mon Sep 17 00:00:00 2001 From: Geoff Pado Date: Thu, 30 May 2024 03:26:14 -0700 Subject: [PATCH] Fix crash in redaction intersections --- Modules/Capabilities/Geometry/Sources/Shape.swift | 9 +++++++++ .../Workspace/PhotoEditingWorkspaceView.swift | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Capabilities/Geometry/Sources/Shape.swift b/Modules/Capabilities/Geometry/Sources/Shape.swift index a1259fca..e7879ddd 100644 --- a/Modules/Capabilities/Geometry/Sources/Shape.swift +++ b/Modules/Capabilities/Geometry/Sources/Shape.swift @@ -113,6 +113,15 @@ public struct Shape: Hashable { let area = 0.5 * abs(shoelace) return abs(area) > 0.01 } + + public var integral: Shape { + return Shape( + bottomLeft: CGPoint(x: Int(bottomLeft.x - 0.5), y: Int(bottomLeft.y + 0.5)), + bottomRight: CGPoint(x: Int(bottomRight.x + 0.5), y: Int(bottomRight.y + 0.5)), + topLeft: CGPoint(x: Int(topLeft.x - 0.5), y: Int(topLeft.y - 0.5)), + topRight: CGPoint(x: Int(topRight.x + 0.5), y: Int(topRight.y - 0.5)) + ) + } } extension CGPoint: Hashable { diff --git a/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift b/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift index ae02cb5e..2b7adc84 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Workspace/PhotoEditingWorkspaceView.swift @@ -121,8 +121,8 @@ class PhotoEditingWorkspaceView: UIControl, UIGestureRecognizerDelegate { Task.detached { [weak self] in let filteredTextCharacterObservations = textCharacterObservations.filter { characterObservation in let hasIntersection = wordObservations.contains { wordObservation in - let wordCGPath = wordObservation.bounds.path - let textCGPath = characterObservation.bounds.path + let wordCGPath = wordObservation.bounds.integral.path + let textCGPath = characterObservation.bounds.integral.path let textPath = UIBezierPath(cgPath: textCGPath) let wordPath = UIBezierPath(cgPath: wordCGPath)