mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Fixed transparent background in ResizeCanvas dialog
It was always square, even on non-square image dimensions.
This commit is contained in:
parent
d31509035f
commit
d099666abe
|
@ -19,6 +19,7 @@ Darshan Phaldesai (luiq54), Igor Santarek (jegor377), rob-a-bolton, Kinwailo
|
|||
- You can now preview how the frames of the spritesheet you are importing will look.
|
||||
- You can now import image files as layers. Their size will be cropped to the project's size.
|
||||
- You can import image files as brushes, patterns and palettes.
|
||||
- Added "Copy", "Paste" and "Delete" options in the Edit menu. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281))
|
||||
- Selection region and size are now being shown when making a selection on the top, next to the position label. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281))
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -127,8 +127,8 @@ func spritesheet_frame_value_changed(value : int, vertical : bool) -> void:
|
|||
var scale_ratio = image.get_size().y / image_size_y
|
||||
image_size_x = image.get_size().x / scale_ratio
|
||||
|
||||
var offset_x = (300 - image_size_x) / 2
|
||||
var offset_y = (300 - image_size_y) / 2
|
||||
var offset_x = (texture_rect.rect_size.x - image_size_x) / 2
|
||||
var offset_y = (texture_rect.rect_size.y - image_size_y) / 2
|
||||
|
||||
if value > 1:
|
||||
var line_distance
|
||||
|
|
|
@ -39,8 +39,8 @@ func _on_ResizeCanvas_about_to_show() -> void:
|
|||
layer_i += 1
|
||||
image.unlock()
|
||||
|
||||
update_preview()
|
||||
preview_rect.get_node("TransparentChecker").rect_size = preview_rect.rect_size
|
||||
update_preview()
|
||||
|
||||
|
||||
func _on_ResizeCanvas_confirmed() -> void:
|
||||
|
@ -86,3 +86,18 @@ func update_preview() -> void:
|
|||
var preview_texture := ImageTexture.new()
|
||||
preview_texture.create_from_image(preview_image, 0)
|
||||
preview_rect.texture = preview_texture
|
||||
update_transparent_background_size(preview_image)
|
||||
|
||||
|
||||
func update_transparent_background_size(preview_image : Image) -> void:
|
||||
var image_size_y = preview_rect.rect_size.y
|
||||
var image_size_x = preview_rect.rect_size.x
|
||||
if preview_image.get_size().x > preview_image.get_size().y:
|
||||
var scale_ratio = preview_image.get_size().x / image_size_x
|
||||
image_size_y = preview_image.get_size().y / scale_ratio
|
||||
else:
|
||||
var scale_ratio = preview_image.get_size().y / image_size_y
|
||||
image_size_x = preview_image.get_size().x / scale_ratio
|
||||
|
||||
preview_rect.get_node("TransparentChecker").rect_size.x = image_size_x
|
||||
preview_rect.get_node("TransparentChecker").rect_size.y = image_size_y
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[node name="ResizeCanvas" type="ConfirmationDialog"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 114.0
|
||||
resizable = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
|
@ -116,8 +117,10 @@ margin_top = 172.0
|
|||
margin_right = 200.0
|
||||
margin_bottom = 372.0
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="TransparentChecker" parent="VBoxContainer/Preview" instance=ExtResource( 2 )]
|
||||
show_behind_parent = true
|
||||
|
|
Loading…
Reference in a new issue