Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. paths = paths.filter { !$0.contains(touchPoint) }
  2.  
  3. static func convertStrokePathToFillPath(_ path: UIBezierPath) throws -> UIBezierPath {
  4. UIGraphicsBeginImageContextWithOptions(CGSize(width: 1.0, height: 1.0), true, 1.0)
  5. guard let context = UIGraphicsGetCurrentContext() else { throw NSError(domain: "convertStrokePathToFillPath", code: 500, userInfo: ["dev_message":"Could not generate image context"]) }
  6.  
  7. context.addPath(path.cgPath)
  8. context.setLineWidth(path.lineWidth)
  9. // TODO: apply all possible settings from path to context
  10. context.replacePathWithStrokedPath()
  11.  
  12. guard let returnedPath = context.path else { throw NSError(domain: "convertStrokePathToFillPath", code: 500, userInfo: ["dev_message":"Could not get path from context"]) }
  13. UIGraphicsEndImageContext()
  14.  
  15. return UIBezierPath(cgPath: returnedPath)
  16. }
  17.  
  18. static func filterPaths(_ paths: [UIBezierPath], containingPoint point: CGPoint) -> [UIBezierPath] {
  19. return paths.filter { !(try! convertStrokePathToFillPath($0).contains(point)) }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement