Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum PathType {
- case yolo, vision
- }
- private let yoloPath = UIBezierPath()
- private let visionPath = UIBezierPath()
- private let yoloLayer = CAShapeLayer()
- private let visionLayer = CAShapeLayer()
- private var previousTouchPoint = CGPoint.zero
- func drawPath(at point: CGPoint, pathType: PathType) {
- let path: UIBezierPath
- let shapeLayer: CAShapeLayer
- switch pathType {
- case .yolo:
- path = yoloPath
- shapeLayer = yoloLayer
- case .vision:
- path = visionPath
- shapeLayer = visionLayer
- }
- path.move(to: point)
- if self.previousTouchPoint != CGPoint.zero {
- path.addLine(to: self.previousTouchPoint)
- }
- self.previousTouchPoint = point
- shapeLayer.path = path.cgPath
- switch pathType {
- case .yolo:
- shapeLayer.strokeColor = UIColor.red.cgColor
- case .vision:
- shapeLayer.strokeColor = UIColor.green.cgColor
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement