1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fix drawing bug reported in issue-555 (#603)

* Fix drawing bug reported in issue-555

* Remove unused parameter from commit_undo() in Draw.gd
This commit is contained in:
JumpJetAvocado 2021-12-07 01:38:54 +09:00 committed by GitHub
parent af86856dc6
commit fa27d7fbad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 13 deletions

View file

@ -146,11 +146,13 @@ func update_line_polylines(start: Vector2, end: Vector2) -> void:
_line_polylines = _create_polylines(indicator) _line_polylines = _create_polylines(indicator)
func prepare_undo() -> void: func prepare_undo(action: String) -> void:
var project: Project = Global.current_project
_undo_data = _get_undo_data() _undo_data = _get_undo_data()
project.undo_redo.create_action(action)
func commit_undo(action: String) -> void: func commit_undo() -> void:
var redo_data := _get_undo_data() var redo_data := _get_undo_data()
var project: Project = Global.current_project var project: Project = Global.current_project
var frame := -1 var frame := -1
@ -160,7 +162,6 @@ func commit_undo(action: String) -> void:
layer = project.current_layer layer = project.current_layer
project.undos += 1 project.undos += 1
project.undo_redo.create_action(action)
for image in redo_data: for image in redo_data:
project.undo_redo.add_do_property(image, "data", redo_data[image]) project.undo_redo.add_do_property(image, "data", redo_data[image])
image.unlock() image.unlock()

View file

@ -46,7 +46,7 @@ func draw_start(position: Vector2) -> void:
_changed = false _changed = false
_drawer.color_op.changed = false _drawer.color_op.changed = false
prepare_undo() prepare_undo("Draw")
_drawer.reset() _drawer.reset()
_draw_line = Tools.shift _draw_line = Tools.shift
@ -88,7 +88,7 @@ func draw_end(_position: Vector2) -> void:
draw_fill_gap(_line_start, _line_end) draw_fill_gap(_line_start, _line_end)
_draw_line = false _draw_line = false
if _changed or _drawer.color_op.changed: if _changed or _drawer.color_op.changed:
commit_undo("Draw") commit_undo()
cursor_text = "" cursor_text = ""
update_random_image() update_random_image()

View file

@ -148,14 +148,14 @@ func draw_preview() -> void:
func _draw_shape() -> void: func _draw_shape() -> void:
# var rect := _get_result_rect(origin, dest) # var rect := _get_result_rect(origin, dest)
var points := _get_points() var points := _get_points()
prepare_undo() prepare_undo("Draw Shape")
for point in points: for point in points:
# Reset drawer every time because pixel perfect sometimes breaks the tool # Reset drawer every time because pixel perfect sometimes breaks the tool
_drawer.reset() _drawer.reset()
# Draw each point offseted based on the shape's thickness # Draw each point offseted based on the shape's thickness
draw_tool(point) draw_tool(point)
commit_undo("Draw Shape") commit_undo()
func _get_points() -> PoolVector2Array: func _get_points() -> PoolVector2Array:

View file

@ -83,7 +83,7 @@ func draw_start(position: Vector2) -> void:
_drawer.color_op.overwrite = _overwrite _drawer.color_op.overwrite = _overwrite
_draw_points = Array() _draw_points = Array()
prepare_undo() prepare_undo("Draw")
_drawer.reset() _drawer.reset()
_draw_line = Tools.shift _draw_line = Tools.shift
@ -141,7 +141,7 @@ func draw_end(_position: Vector2) -> void:
if Geometry.is_point_in_polygon(v, _draw_points): if Geometry.is_point_in_polygon(v, _draw_points):
draw_tool(v) draw_tool(v)
if _changed or _drawer.color_op.changed: if _changed or _drawer.color_op.changed:
commit_undo("Draw") commit_undo()
cursor_text = "" cursor_text = ""
update_random_image() update_random_image()

View file

@ -221,7 +221,7 @@ func draw_start(position: Vector2) -> void:
_changed = false _changed = false
_drawer.color_op.changed = false _drawer.color_op.changed = false
prepare_undo() prepare_undo("Draw")
_drawer.reset() _drawer.reset()
_draw_line = Tools.shift _draw_line = Tools.shift
@ -263,7 +263,7 @@ func draw_end(_position: Vector2) -> void:
draw_fill_gap(_line_start, _line_end) draw_fill_gap(_line_start, _line_end)
_draw_line = false _draw_line = false
if _changed or _drawer.color_op.changed: if _changed or _drawer.color_op.changed:
commit_undo("Draw") commit_undo()
cursor_text = "" cursor_text = ""
update_random_image() update_random_image()

View file

@ -149,14 +149,14 @@ func draw_preview() -> void:
func _draw_shape(origin: Vector2, dest: Vector2) -> void: func _draw_shape(origin: Vector2, dest: Vector2) -> void:
var rect := _get_result_rect(origin, dest) var rect := _get_result_rect(origin, dest)
var points := _get_points(rect.size) var points := _get_points(rect.size)
prepare_undo() prepare_undo("Draw Shape")
for point in points: for point in points:
# Reset drawer every time because pixel perfect sometimes breaks the tool # Reset drawer every time because pixel perfect sometimes breaks the tool
_drawer.reset() _drawer.reset()
# Draw each point offseted based on the shape's thickness # Draw each point offseted based on the shape's thickness
draw_tool(rect.position + point - Vector2.ONE * (_thickness - 1)) draw_tool(rect.position + point - Vector2.ONE * (_thickness - 1))
commit_undo("Draw Shape") commit_undo()
# Given an origin point and destination point, returns a rect representing # Given an origin point and destination point, returns a rect representing