                 guard touch.view === self else {
                     continue
                 }
-
+                guard let line = lines[touch] else {
+                    continue
+                }
                 let coalescedTouchs = event?.coalescedTouches(for: touch) ?? []
-                // TODO: also handle estimated touches?
-                // XXX:
-                for coalescedTouch in coalescedTouchs {
-                    context.beginPath()
-                    let point = coalescedTouch.preciseLocation(in: self)
-                    print("@@@@@ draw \(point)")
-                    context.move(to: point)
+                let points = coalescedTouchs.map { [unowned self] coalescedTouch in
+                    return coalescedTouch.preciseLocation(in: self)
+                }
+                context.beginPath()
+                context.move(to: line.lastPoint)
+                for point in points {
                     context.addLine(to: point)
                     context.setLineWidth(5)
-                    context.strokePath()
                 }
+                context.strokePath()
+                line.lastPoint = points.last!
             }
             // XXX:
             context.restoreGState()


import UIKit

final class SignaturePad: UIView {
    fileprivate var frozenCanvas: FrozenCanvas!

    var frozenImage: CGImage {

// MARK: Handle touches
extension SignaturePad {
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        for touch in touches {
            // do not process touches from subviews
            guard touch.view === self else {
                continue
            }
            let line = Line(startPoint: touch.preciseLocation(in: self))
            lines[touch] = line

            let coalescedTouchs = event?.coalescedTouches(for: touch) ?? []
            print("@@@@@@ \(touch) \(coalescedTouchs)")
            // TODO: draw stuff?
            /*
            if let line = lines[touch] {
                if let lastTouch = coalescedTouchs.last {
                    line.lastPoint = lastTouch.location(in: self)
                    print("!!!!! first last point for \(touch)")
                }
            }*/
        }
        // TODO:
    }

