1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Implemented pinch gesture to scale adventure map

This commit is contained in:
Ivan Savenko
2023-05-31 16:15:15 +03:00
parent a08ff1e6ef
commit 0f2a339ab5
8 changed files with 92 additions and 6 deletions

View File

@@ -91,9 +91,9 @@ void MapViewController::modifyTileSize(int stepsChange)
// so, zooming in for 5 steps will put game at 1.1^5 = 1.61 scale
// try to determine current zooming level and change it by requested number of steps
double currentZoomFactor = model->getSingleTileSize().x / 32.0;
double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.1));
double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.01));
double newZoomSteps = stepsChange != 0 ? currentZoomSteps + stepsChange : stepsChange;
double newZoomFactor = std::pow(1.1, newZoomSteps);
double newZoomFactor = std::pow(1.01, newZoomSteps);
Point currentZoom = model->getSingleTileSize();
Point desiredZoom = Point(32,32) * newZoomFactor;