1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-30 23:19:49 +00:00

Improved the "fit to frame" zoom button

The resulting camera zoom now depends on the window size. More specifically, the main viewport's x size. This formula is purely trial-and-error, and it may not work perfectly, or properly for some screen sizes.

If anyone wants to improve it, feel free to do so!
This commit is contained in:
OverloadedOrama 2020-04-13 16:39:18 +03:00
parent 7d2b15cc0b
commit bdd3cdf45e
3 changed files with 9 additions and 9 deletions

View file

@ -654,7 +654,7 @@ func _on_RightZoomModeOptions_item_selected(ID : int) -> void:
func _on_FitToFrameButton_pressed() -> void:
var bigger = max(Global.canvas.size.x, Global.canvas.size.y)
Global.camera.zoom = Vector2(bigger, bigger) * 0.002
Global.camera.zoom = (Vector2(bigger, bigger) * 0.004) / (Global.main_viewport.rect_size.x * 0.002)
Global.camera.offset = Global.canvas.size / 2
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"