Created
January 16, 2019 04:33
-
-
Save almaleh/926378763df622f2671237797c15d0f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { | |
guard let newTouchPoint = touches.first?.location(in: self) else { return } | |
var lastTouchPoint: CGPoint = .zero | |
if let lastIndex = lines.indices.last { | |
// get reference to last point | |
if let lastPoint = lines[lastIndex].last { lastTouchPoint = lastPoint } | |
// add new point | |
lines[lastIndex].append(newTouchPoint) | |
} | |
let rect = calculateRectBetween(lastPoint: lastTouchPoint, newPoint: newTouchPoint) | |
setNeedsDisplay(rect) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment