diff options
| author | Mike Will <[email protected]> | 2024-05-15 10:19:22 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-15 16:19:22 +0200 |
| commit | 46f98063597648227cfa6fbe96c189ed970faea8 (patch) | |
| tree | de6f4b15b59427830398368840d7bd8ab9ac4d7e /examples/core | |
| parent | bf5eecc71f63d1bca76fdb377a1d231066f9258d (diff) | |
| download | raylib-46f98063597648227cfa6fbe96c189ed970faea8.tar.gz raylib-46f98063597648227cfa6fbe96c189ed970faea8.zip | |
Use logarithmic scaling for a 2d example with zoom functionality (#3977)
Diffstat (limited to 'examples/core')
| -rw-r--r-- | examples/core/core_2d_camera_mouse_zoom.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/core/core_2d_camera_mouse_zoom.c b/examples/core/core_2d_camera_mouse_zoom.c index abc6a6d1..b96a3db4 100644 --- a/examples/core/core_2d_camera_mouse_zoom.c +++ b/examples/core/core_2d_camera_mouse_zoom.c @@ -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); } //---------------------------------------------------------------------------------- |
