mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-22 05:23:14 +00:00
Fix a bug in integer zoom (#896)
* Update CameraMovement.gd * improvement to correction in fit to frame
This commit is contained in:
parent
74e3ff9f0b
commit
edc6ba5944
1 changed files with 10 additions and 0 deletions
|
@ -139,6 +139,8 @@ func zoom_camera(dir: int) -> void:
|
||||||
var new_zoom := zoom + zoom_margin
|
var new_zoom := zoom + zoom_margin
|
||||||
if Global.integer_zoom:
|
if Global.integer_zoom:
|
||||||
new_zoom = zoom / (Vector2.ONE - dir * zoom)
|
new_zoom = zoom / (Vector2.ONE - dir * zoom)
|
||||||
|
if new_zoom == Vector2.INF:
|
||||||
|
return
|
||||||
if new_zoom > zoom_min && new_zoom <= zoom_max:
|
if new_zoom > zoom_min && new_zoom <= zoom_max:
|
||||||
var new_offset := (
|
var new_offset := (
|
||||||
offset
|
offset
|
||||||
|
@ -154,6 +156,8 @@ func zoom_camera(dir: int) -> void:
|
||||||
var zoom_margin := zoom * dir / 10
|
var zoom_margin := zoom * dir / 10
|
||||||
if Global.integer_zoom:
|
if Global.integer_zoom:
|
||||||
zoom_margin = (zoom / (Vector2.ONE - dir * zoom)) - zoom
|
zoom_margin = (zoom / (Vector2.ONE - dir * zoom)) - zoom
|
||||||
|
if zoom_margin == Vector2.INF:
|
||||||
|
return
|
||||||
if zoom + zoom_margin > zoom_min:
|
if zoom + zoom_margin > zoom_min:
|
||||||
zoom += zoom_margin
|
zoom += zoom_margin
|
||||||
if zoom > zoom_max:
|
if zoom > zoom_max:
|
||||||
|
@ -192,6 +196,10 @@ func zoom_100() -> void:
|
||||||
|
|
||||||
|
|
||||||
func fit_to_frame(size: Vector2) -> void:
|
func fit_to_frame(size: Vector2) -> void:
|
||||||
|
# temporarily disable integer zoom
|
||||||
|
var reset_integer_zoom := Global.integer_zoom
|
||||||
|
if reset_integer_zoom:
|
||||||
|
Global.integer_zoom = !Global.integer_zoom
|
||||||
offset = size / 2
|
offset = size / 2
|
||||||
|
|
||||||
# Adjust to the rotated size:
|
# Adjust to the rotated size:
|
||||||
|
@ -226,6 +234,8 @@ func fit_to_frame(size: Vector2) -> void:
|
||||||
ratio = clamp(ratio, 0.1, ratio)
|
ratio = clamp(ratio, 0.1, ratio)
|
||||||
zoom = Vector2(1 / ratio, 1 / ratio)
|
zoom = Vector2(1 / ratio, 1 / ratio)
|
||||||
emit_signal("zoom_changed")
|
emit_signal("zoom_changed")
|
||||||
|
if reset_integer_zoom:
|
||||||
|
Global.integer_zoom = !Global.integer_zoom
|
||||||
|
|
||||||
|
|
||||||
func save_values_to_project() -> void:
|
func save_values_to_project() -> void:
|
||||||
|
|
Loading…
Add table
Reference in a new issue