-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
I've updated the touchesBegan function in my forked repo to experiment adding a 'continue path' functionality, where the line you draw will automatically continue from the last one you did (if it exists)
Is something like this worth adding into the library?
The updated touchesBegan() looks like
/// Determines whether the path should continue from the last touch point.
public var shouldContinuePath = false
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard isEnabled, let touch = touches.first else { return }
if #available(iOS 9.1, *) {
guard allowedTouchTypes.flatMap({ $0.uiTouchTypes }).contains(touch.type) else { return }
}
guard delegate?.swiftyDraw(shouldBeginDrawingIn: self, using: touch) ?? true else { return }
delegate?.swiftyDraw(didBeginDrawingIn: self, using: touch)
firstPoint = shouldContinuePath && previousPoint != .zero ? previousPoint : touch.location(in: self)
setTouchPoints(touch, view: self)
let newLine = DrawItem(path: CGMutablePath(),
brush: Brush(color: brush.color.uiColor, width: brush.width, opacity: brush.opacity, blendMode: brush.blendMode), isFillPath: false)
if shouldContinuePath && currentPoint != .zero {
// draw a straight line between the end of the last touch point
// and this new touch point
newLine.path.addPath(createNewStraightPath())
}
addLine(newLine)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
