You might see the velocity
parameter in a gesture. This parameter is a representation of the speed of movement of the gesture between the current event and previous event. It is also measured by the change in the center
.
obj.addPanGestureRecognizer { locations, center, translation, velocity, state in
print(velocity)
}
Velocity can vary greatly, depending on how fast the user moves their touches. For example, it can range from 0…3000+, so you’ll have to calibrate a bit like we do in the example below.
let c = Circle(center: canvas.center, radius: 100)
canvas.add(c)
canvas.addPanGestureRecognizer { locations, center, translation, velocity, state in
c.center = center
c.lineWidth = velocity.magnitude / 10.0
}