Skip to content

Commit

Permalink
Use logarithmic scaling for a 2d example with zoom functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
myQwil committed May 13, 2024
1 parent f622021 commit d8719ec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/core/core_2d_camera_mouse_zoom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//----------------------------------------------------------------------------------
Expand Down

0 comments on commit d8719ec

Please sign in to comment.