diff --git a/src/Classes/Drawers.gd b/src/Classes/Drawers.gd index d7342c98c..099ad5e06 100644 --- a/src/Classes/Drawers.gd +++ b/src/Classes/Drawers.gd @@ -66,9 +66,11 @@ func set_pixel_perfect(value: bool) -> void: drawers = [simple_drawer, simple_drawer, simple_drawer, simple_drawer] -func set_pixel(image: Image, position: Vector2, color: Color) -> void: +func set_pixel(image: Image, position: Vector2, color: Color, ignore_mirroring := false) -> void: var project : Project = Global.current_project drawers[0].set_pixel(image, position, color, color_op) + if ignore_mirroring: + return # Handle Mirroring var mirror_x = project.x_symmetry_point - position.x diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index b5b4dea77..bf9e9bbd8 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -339,7 +339,7 @@ func draw_indicator_at(position : Vector2, offset : Vector2, color : Color) -> v canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale) -func _set_pixel(position : Vector2) -> void: +func _set_pixel(position : Vector2, ignore_mirroring := false) -> void: var project : Project = Global.current_project if project.tile_mode and project.get_tile_mode_rect().has_point(position): position = position.posmodv(project.size) @@ -353,9 +353,9 @@ func _set_pixel(position : Vector2) -> void: if _mask.size() >= i + 1: if _mask[i] < Tools.pen_pressure: _mask[i] = Tools.pen_pressure - _drawer.set_pixel(image, position, tool_slot.color) + _drawer.set_pixel(image, position, tool_slot.color, ignore_mirroring) else: - _drawer.set_pixel(image, position, tool_slot.color) + _drawer.set_pixel(image, position, tool_slot.color, ignore_mirroring) func _draw_brush_image(_image : Image, _src_rect: Rect2, _dst: Vector2) -> void: diff --git a/src/Tools/Eraser.gd b/src/Tools/Eraser.gd index eb20df543..842faa4b7 100644 --- a/src/Tools/Eraser.gd +++ b/src/Tools/Eraser.gd @@ -68,12 +68,12 @@ func draw_end(_position : Vector2) -> void: update_random_image() -func _draw_brush_image(_image : Image, src_rect: Rect2, dst: Vector2) -> void: +func _draw_brush_image(image : Image, src_rect: Rect2, dst: Vector2) -> void: _changed = true - var size := _image.get_size() + var size := image.get_size() if _clear_image.get_size() != size: _clear_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST) var images := _get_selected_draw_images() for draw_image in images: - draw_image.blit_rect_mask(_clear_image, _image, src_rect, dst) + draw_image.blit_rect_mask(_clear_image, image, src_rect, dst) diff --git a/src/Tools/Shading.gd b/src/Tools/Shading.gd index a2d32eaaf..f14e8d0d6 100644 --- a/src/Tools/Shading.gd +++ b/src/Tools/Shading.gd @@ -23,8 +23,8 @@ class LightenDarkenOp extends Drawer.ColorOp: var sat_amount := 10.0 var value_amount := 10.0 - var hue_lighten_limit := 60.0 / 359.0 - var hue_darken_limit := 270.0 / 359.0 + var hue_lighten_limit := 60.0 / 359.0 # A yellow color + var hue_darken_limit := 270.0 / 359.0 # A purple color var sat_lighten_limit := 10.0 / 100.0 var value_darken_limit := 10.0 / 100.0 @@ -244,6 +244,12 @@ func draw_end(_position : Vector2) -> void: update_random_image() -func _draw_brush_image(_image : Image, _src_rect: Rect2, _dst: Vector2) -> void: +func _draw_brush_image(image : Image, src_rect: Rect2, dst: Vector2) -> void: _changed = true - draw_tool_pixel(_cursor.floor()) + image.lock() + for xx in image.get_size().x: + for yy in image.get_size().y: + if image.get_pixel(xx, yy).a > 0: + var pos := Vector2(xx, yy) + dst - src_rect.position + _set_pixel(pos, true) + image.unlock() diff --git a/src/Tools/Shading.tscn b/src/Tools/Shading.tscn index eff647b65..3610af186 100644 --- a/src/Tools/Shading.tscn +++ b/src/Tools/Shading.tscn @@ -3,7 +3,6 @@ [ext_resource path="res://src/Tools/Draw.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Tools/Shading.gd" type="Script" id=2] - [node name="ToolOptions" instance=ExtResource( 1 )] script = ExtResource( 2 ) @@ -154,7 +153,6 @@ margin_bottom = 42.0 hint_tooltip = "Lighten/Darken amount" mouse_default_cursor_shape = 2 size_flags_horizontal = 4 -max_value = 100.0 value = 10.0 align = 1 @@ -169,7 +167,6 @@ focus_mode = 0 mouse_default_cursor_shape = 2 size_flags_horizontal = 4 size_flags_vertical = 1 -max_value = 100.0 value = 10.0 ticks_on_borders = true @@ -194,7 +191,6 @@ margin_bottom = 42.0 hint_tooltip = "Lighten/Darken amount" mouse_default_cursor_shape = 2 size_flags_horizontal = 4 -max_value = 100.0 value = 10.0 align = 1 @@ -209,7 +205,6 @@ focus_mode = 0 mouse_default_cursor_shape = 2 size_flags_horizontal = 4 size_flags_vertical = 1 -max_value = 100.0 value = 10.0 ticks_on_borders = true @@ -247,6 +242,7 @@ margin_right = 40.0 [node name="Vertical" parent="Mirror" index="1"] margin_left = 84.0 margin_right = 101.0 + [connection signal="item_selected" from="ShadingMode" to="." method="_on_ShadingMode_item_selected"] [connection signal="item_selected" from="LightenDarken" to="." method="_on_LightenDarken_item_selected"] [connection signal="value_changed" from="Amount/Spinbox" to="." method="_on_LightenDarken_value_changed"]