void Scroll(GuiElement sender, PointF MousePos, int Dir) { if (EnableInteraction && Main.PolynomialAnimationTimer >= 1) { if (Controller.MeshActive) { if (Dir < 0) { Controller.CameraDistance *= 1.2; } else if (Dir > 0) { Controller.CameraDistance /= 1.2; } } else { double ScaleFactor = 1; if (Dir < 0) { ScaleFactor = ZoomSpeed; } else if (Dir > 0) { ScaleFactor = 1 / ZoomSpeed; } Complex CurrentPos = GetWorldFromScreen(new Vector2(MousePos.X, MousePos.Y)); CurrentPos -= Controller.CameraPos; CurrentPos += Controller.CameraPos; Controller.CameraPos = Controller.CameraPos * ScaleFactor + CurrentPos * (1 - ScaleFactor); Controller.Zoom *= ScaleFactor; Controller.Compute(); } } }