mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Add Flip X, Flip Y, Rotate 90, Rotate 180, Rotate 270
This commit is contained in:
parent
693ca36b26
commit
afacaf5257
|
@ -3,6 +3,11 @@ extends BaseTool
|
|||
var _brush := Brushes.get_default_brush()
|
||||
var _brush_size := 1
|
||||
var _brush_size_dynamics := 1
|
||||
var _brush_flip_x := false
|
||||
var _brush_flip_y := false
|
||||
var _brush_rotate_90 := false
|
||||
var _brush_rotate_180 := false
|
||||
var _brush_rotate_270 := false
|
||||
var _cache_limit := 3
|
||||
var _brush_interpolate := 0
|
||||
var _brush_image := Image.new()
|
||||
|
@ -122,6 +127,11 @@ func set_config(config: Dictionary) -> void:
|
|||
func update_config() -> void:
|
||||
$Brush/BrushSize.value = _brush_size
|
||||
$ColorInterpolation.value = _brush_interpolate
|
||||
$Flip/FlipX.button_pressed = _brush_flip_x
|
||||
$Flip/FlipY.button_pressed = _brush_flip_y
|
||||
$Rotate/Rotate90.button_pressed = _brush_rotate_90
|
||||
$Rotate/Rotate180.button_pressed = _brush_rotate_180
|
||||
$Rotate/Rotate270.button_pressed = _brush_rotate_270
|
||||
update_brush()
|
||||
|
||||
|
||||
|
@ -151,12 +161,15 @@ func update_brush() -> void:
|
|||
var random := randi() % _brush.random.size()
|
||||
_orignal_brush_image = _brush.random[random]
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
update_brush_image_flip_and_rotate()
|
||||
_brush_texture = ImageTexture.create_from_image(_brush_image)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
_indicator = _create_brush_indicator()
|
||||
_polylines = _create_polylines(_indicator)
|
||||
$Brush/Type/Texture.texture = _brush_texture
|
||||
#$Brush/Type/Texture.set_flip_v(Tools.brush_flip_x)
|
||||
#$Brush/Type/Texture.set_flip_h(Tools.brush_flip_y)
|
||||
$ColorInterpolation.visible = _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM]
|
||||
|
||||
|
||||
|
@ -166,6 +179,7 @@ func update_random_image() -> void:
|
|||
var random := randi() % _brush.random.size()
|
||||
_brush_image = _create_blended_brush_image(_brush.random[random])
|
||||
_orignal_brush_image = _brush_image
|
||||
update_brush_image_flip_and_rotate()
|
||||
_brush_texture = ImageTexture.create_from_image(_brush_image)
|
||||
_indicator = _create_brush_indicator()
|
||||
update_mirror_brush()
|
||||
|
@ -180,6 +194,19 @@ func update_mirror_brush() -> void:
|
|||
_mirror_brushes.xy.flip_y()
|
||||
|
||||
|
||||
func update_brush_image_flip_and_rotate() -> void:
|
||||
if _brush_flip_x == true:
|
||||
_brush_image.flip_x()
|
||||
if _brush_flip_y == true:
|
||||
_brush_image.flip_y()
|
||||
if _brush_rotate_90 == true:
|
||||
_brush_image.rotate_90(CLOCKWISE)
|
||||
if _brush_rotate_180 == true:
|
||||
_brush_image.rotate_180()
|
||||
if _brush_rotate_270 == true:
|
||||
_brush_image.rotate_90(COUNTERCLOCKWISE)
|
||||
|
||||
|
||||
func update_mask(can_skip := true) -> void:
|
||||
if can_skip and Tools.dynamics_alpha == Tools.Dynamics.NONE:
|
||||
if _mask:
|
||||
|
@ -241,6 +268,7 @@ func draw_end(pos: Vector2i) -> void:
|
|||
match _brush.type:
|
||||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
update_brush_image_flip_and_rotate()
|
||||
_brush_texture = ImageTexture.create_from_image(_brush_image)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
|
@ -279,6 +307,7 @@ func _prepare_tool() -> void:
|
|||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
||||
# save _brush_image for safe keeping
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
update_brush_image_flip_and_rotate()
|
||||
_brush_texture = ImageTexture.create_from_image(_brush_image)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
|
@ -707,3 +736,29 @@ func _pick_color(pos: Vector2i) -> void:
|
|||
else MOUSE_BUTTON_RIGHT
|
||||
)
|
||||
Tools.assign_color(color, button, false)
|
||||
|
||||
|
||||
|
||||
func _on_flip_x_toggled(button_pressed: bool) -> void:
|
||||
_brush_flip_x = button_pressed
|
||||
update_brush()
|
||||
|
||||
|
||||
func _on_flip_y_toggled(button_pressed: bool) -> void:
|
||||
_brush_flip_y = button_pressed
|
||||
update_brush()
|
||||
|
||||
|
||||
func _on_rotate_90_toggled(button_pressed: bool) -> void:
|
||||
_brush_rotate_90 = button_pressed
|
||||
update_brush()
|
||||
|
||||
|
||||
func _on_rotate_180_toggled(button_pressed: bool) -> void:
|
||||
_brush_rotate_180 = button_pressed
|
||||
update_brush()
|
||||
|
||||
|
||||
func _on_rotate_270_toggled(button_pressed: bool) -> void:
|
||||
_brush_rotate_270 = button_pressed
|
||||
update_brush()
|
||||
|
|
|
@ -25,7 +25,33 @@ anti_aliasing = false
|
|||
[node name="ToolOptions" instance=ExtResource("2")]
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="Brush" type="HBoxContainer" parent="." index="2"]
|
||||
[node name="Flip" type="HBoxContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FlipX" type="CheckBox" parent="Flip" index="0"]
|
||||
layout_mode = 2
|
||||
text = "Flip X"
|
||||
|
||||
[node name="FlipY" type="CheckBox" parent="Flip" index="1"]
|
||||
layout_mode = 2
|
||||
text = "Flip Y"
|
||||
|
||||
[node name="Rotate" type="HBoxContainer" parent="." index="3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Rotate90" type="CheckBox" parent="Rotate" index="0"]
|
||||
layout_mode = 2
|
||||
text = "R 90"
|
||||
|
||||
[node name="Rotate180" type="CheckBox" parent="Rotate" index="1"]
|
||||
layout_mode = 2
|
||||
text = "R 180"
|
||||
|
||||
[node name="Rotate270" type="CheckBox" parent="Rotate" index="2"]
|
||||
layout_mode = 2
|
||||
text = "R 270"
|
||||
|
||||
[node name="Brush" type="HBoxContainer" parent="." index="4"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
|
@ -59,12 +85,17 @@ suffix = "px"
|
|||
global_increment_action = "brush_size_increment"
|
||||
global_decrement_action = "brush_size_decrement"
|
||||
|
||||
[node name="ColorInterpolation" parent="." index="3" instance=ExtResource("1")]
|
||||
[node name="ColorInterpolation" parent="." index="5" instance=ExtResource("1")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
tooltip_text = "0: Color from the brush itself, 100: the currently selected color"
|
||||
prefix = "Brush color from:"
|
||||
|
||||
[connection signal="toggled" from="Flip/FlipX" to="." method="_on_flip_x_toggled"]
|
||||
[connection signal="toggled" from="Flip/FlipY" to="." method="_on_flip_y_toggled"]
|
||||
[connection signal="toggled" from="Rotate/Rotate90" to="." method="_on_rotate_90_toggled"]
|
||||
[connection signal="toggled" from="Rotate/Rotate180" to="." method="_on_rotate_180_toggled"]
|
||||
[connection signal="toggled" from="Rotate/Rotate270" to="." method="_on_rotate_270_toggled"]
|
||||
[connection signal="pressed" from="Brush/Type" to="." method="_on_BrushType_pressed"]
|
||||
[connection signal="value_changed" from="Brush/BrushSize" to="." method="_on_BrushSize_value_changed"]
|
||||
[connection signal="value_changed" from="ColorInterpolation" to="." method="_on_InterpolateFactor_value_changed"]
|
||||
|
|
Loading…
Reference in a new issue