Browse Source

Use logarithmic scaling for a 2d example with zoom functionality (#3977)

pull/3983/head
Mike Will 8 months ago
committed by GitHub
parent
commit
46f9806359
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      examples/core/core_2d_camera_mouse_zoom.c

+ 3
- 4
examples/core/core_2d_camera_mouse_zoom.c View File

@ -63,10 +63,9 @@ int main ()
camera.target = mouseWorldPos;
// Zoom increment
const float zoomIncrement = 0.125f;
camera.zoom += (wheel*zoomIncrement);
if (camera.zoom < zoomIncrement) camera.zoom = zoomIncrement;
float scaleFactor = 1.0f + (0.25f * fabsf(wheel));
if (wheel < 0) scaleFactor = 1.0f / scaleFactor;
camera.zoom = Clamp(camera.zoom * scaleFactor, 0.125, 64);
}
//----------------------------------------------------------------------------------

Loading…
Cancel
Save