Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- paths = paths.filter { !$0.contains(touchPoint) }
- static func convertStrokePathToFillPath(_ path: UIBezierPath) throws -> UIBezierPath {
- UIGraphicsBeginImageContextWithOptions(CGSize(width: 1.0, height: 1.0), true, 1.0)
- guard let context = UIGraphicsGetCurrentContext() else { throw NSError(domain: "convertStrokePathToFillPath", code: 500, userInfo: ["dev_message":"Could not generate image context"]) }
- context.addPath(path.cgPath)
- context.setLineWidth(path.lineWidth)
- // TODO: apply all possible settings from path to context
- context.replacePathWithStrokedPath()
- guard let returnedPath = context.path else { throw NSError(domain: "convertStrokePathToFillPath", code: 500, userInfo: ["dev_message":"Could not get path from context"]) }
- UIGraphicsEndImageContext()
- return UIBezierPath(cgPath: returnedPath)
- }
- static func filterPaths(_ paths: [UIBezierPath], containingPoint point: CGPoint) -> [UIBezierPath] {
- return paths.filter { !(try! convertStrokePathToFillPath($0).contains(point)) }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement