mirror of https://github.com/raysan5/raylib
Use logarithmic scaling for a 2d example with zoom functionality (#3977)
This commit is contained in:
parent
bf5eecc71f
commit
46f9806359
|
@ -63,10 +63,9 @@ int main ()
|
||||||
camera.target = mouseWorldPos;
|
camera.target = mouseWorldPos;
|
||||||
|
|
||||||
// Zoom increment
|
// Zoom increment
|
||||||
const float zoomIncrement = 0.125f;
|
float scaleFactor = 1.0f + (0.25f * fabsf(wheel));
|
||||||
|
if (wheel < 0) scaleFactor = 1.0f / scaleFactor;
|
||||||
camera.zoom += (wheel*zoomIncrement);
|
camera.zoom = Clamp(camera.zoom * scaleFactor, 0.125, 64);
|
||||||
if (camera.zoom < zoomIncrement) camera.zoom = zoomIncrement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue