(#54) make scale friction depend on the delta scale

pull/62/head
rexim 5 years ago
parent 984b0ea629
commit eea38a2247

@ -10,8 +10,8 @@ type Config* = object
const defaultConfig* = Config( const defaultConfig* = Config(
scrollSpeed: 1.0, scrollSpeed: 1.0,
dragVelocityFactor: 10.0, dragVelocityFactor: 10.0,
dragFriction: 3.0, dragFriction: 2.0,
scaleFriction: 10.0, scaleFriction: 4.0,
fps: 60 fps: 60
) )

@ -27,7 +27,7 @@ proc update*(camera: var Camera, config: Config, dt: float, mouse: Mouse, image:
let p1 = (mouse.curr - (windowSize * 0.5)) / camera.scale let p1 = (mouse.curr - (windowSize * 0.5)) / camera.scale
camera.position += p0 - p1 camera.position += p0 - p1
camera.delta_scale -= sgn(camera.delta_scale).float * config.scale_friction * dt camera.delta_scale -= camera.delta_scale * dt * config.scale_friction
if not mouse.drag and (camera.velocity.length > VELOCITY_THRESHOLD): if not mouse.drag and (camera.velocity.length > VELOCITY_THRESHOLD):
camera.position += camera.velocity * dt camera.position += camera.velocity * dt

Loading…
Cancel
Save