mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-17 03:24:43 -05:00
Changed zoom fit to frame algorithm, again
Put the new code in a new fit_to_frame() method inside CameraMovement.gd. The old code did not work properly for images with width larger than their height.
This commit is contained in:
parent
74c238b0f5
commit
b4ae097d14
3 changed files with 30 additions and 20 deletions
|
|
@ -791,13 +791,7 @@ func _on_RightZoomModeOptions_item_selected(ID : int) -> void:
|
|||
|
||||
|
||||
func _on_FitToFrameButton_pressed() -> void:
|
||||
var bigger_canvas_axis = max(Global.canvas.size.x, Global.canvas.size.y)
|
||||
var smaller_viewport_axis = min(Global.main_viewport.rect_size.x, Global.main_viewport.rect_size.y)
|
||||
Global.camera.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) / smaller_viewport_axis
|
||||
Global.camera.offset = Global.canvas.size / 2
|
||||
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
||||
Global.horizontal_ruler.update()
|
||||
Global.vertical_ruler.update()
|
||||
Global.camera.fit_to_frame()
|
||||
|
||||
|
||||
func _on_100ZoomButton_pressed() -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue