mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Slightly optimize line and curve tool drawing
This commit is contained in:
parent
df139ed645
commit
cd269c9a4e
|
@ -166,11 +166,12 @@ func draw_preview() -> void:
|
||||||
func _draw_shape() -> void:
|
func _draw_shape() -> void:
|
||||||
var points := _bezier()
|
var points := _bezier()
|
||||||
prepare_undo("Draw Shape")
|
prepare_undo("Draw Shape")
|
||||||
|
var images := _get_selected_draw_images()
|
||||||
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 offsetted based on the shape's thickness
|
# Draw each point offsetted based on the shape's thickness
|
||||||
draw_tool(point)
|
_draw_pixel(point, images)
|
||||||
if _fill:
|
if _fill:
|
||||||
var v := Vector2i()
|
var v := Vector2i()
|
||||||
var image_size := Global.current_project.size
|
var image_size := Global.current_project.size
|
||||||
|
@ -179,11 +180,17 @@ func _draw_shape() -> void:
|
||||||
for y in image_size.y:
|
for y in image_size.y:
|
||||||
v.y = y
|
v.y = y
|
||||||
if Geometry2D.is_point_in_polygon(v, points):
|
if Geometry2D.is_point_in_polygon(v, points):
|
||||||
draw_tool(v)
|
_draw_pixel(v, images)
|
||||||
_clear()
|
_clear()
|
||||||
commit_undo()
|
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:
|
func _clear() -> void:
|
||||||
_curve.clear_points()
|
_curve.clear_points()
|
||||||
_drawing = false
|
_drawing = false
|
||||||
|
|
|
@ -174,14 +174,16 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _draw_shape() -> void:
|
func _draw_shape() -> void:
|
||||||
# var rect := _get_result_rect(origin, dest)
|
|
||||||
var points := _get_points()
|
var points := _get_points()
|
||||||
prepare_undo("Draw Shape")
|
prepare_undo("Draw Shape")
|
||||||
|
var images := _get_selected_draw_images()
|
||||||
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 offsetted based on the shape's thickness
|
# 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()
|
commit_undo()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue