Skip to content
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

Fix crash in redaction intersections #117

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Modules/Capabilities/Geometry/Sources/Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down