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

Slightly optimize line and curve tool drawing

This commit is contained in:
Emmanouil Papadeas 2024-07-31 14:28:30 +03:00
parent df139ed645
commit cd269c9a4e
2 changed files with 13 additions and 4 deletions

View file

@ -166,11 +166,12 @@ func draw_preview() -> void:
func _draw_shape() -> void:
var points := _bezier()
prepare_undo("Draw Shape")
var images := _get_selected_draw_images()
for point in points:
# Reset drawer every time because pixel perfect sometimes breaks the tool
_drawer.reset()
# Draw each point offsetted based on the shape's thickness
draw_tool(point)
_draw_pixel(point, images)
if _fill:
var v := Vector2i()
var image_size := Global.current_project.size
@ -179,11 +180,17 @@ func _draw_shape() -> void:
for y in image_size.y:
v.y = y
if Geometry2D.is_point_in_polygon(v, points):
draw_tool(v)
_draw_pixel(v, images)
_clear()
commit_undo()
func _draw_pixel(point: Vector2i, images: Array[Image]) -> void:
if Global.current_project.can_pixel_get_drawn(point):
for image in images:
_drawer.set_pixel(image, point, tool_slot.color)
func _clear() -> void:
_curve.clear_points()
_drawing = false

View file

@ -174,14 +174,16 @@ func draw_preview() -> void:
func _draw_shape() -> void:
# var rect := _get_result_rect(origin, dest)
var points := _get_points()
prepare_undo("Draw Shape")
var images := _get_selected_draw_images()
for point in points:
# Reset drawer every time because pixel perfect sometimes breaks the tool
_drawer.reset()
# Draw each point offsetted based on the shape's thickness
draw_tool(point)
if Global.current_project.can_pixel_get_drawn(point):
for image in images:
_drawer.set_pixel(image, point, tool_slot.color)
commit_undo()