Skip to content

Commit

Permalink
Fix crash in redaction intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
Arclite committed May 30, 2024
1 parent eb6ab66 commit ec071ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit ec071ff

Please sign in to comment.