mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Add a fill shape checkbox in the curve tool options
Now the curve tool can also be used as a polygon tool
This commit is contained in:
parent
601c25f2dd
commit
318b381938
|
@ -2,6 +2,7 @@ extends "res://src/Tools/BaseDraw.gd"
|
||||||
|
|
||||||
var _curve := Curve2D.new() ## The [Curve2D] responsible for the shape of the curve being drawn.
|
var _curve := Curve2D.new() ## The [Curve2D] responsible for the shape of the curve being drawn.
|
||||||
var _drawing := false ## Set to true when a curve is being drawn.
|
var _drawing := false ## Set to true when a curve is being drawn.
|
||||||
|
var _fill := false ## When true, the inside area of the curve gets filled.
|
||||||
var _editing_bezier := false ## Needed to determine when to show the control points preview line.
|
var _editing_bezier := false ## Needed to determine when to show the control points preview line.
|
||||||
var _thickness := 1 ## The thickness of the curve.
|
var _thickness := 1 ## The thickness of the curve.
|
||||||
|
|
||||||
|
@ -16,13 +17,19 @@ func update_brush() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _on_Thickness_value_changed(value: int) -> void:
|
func _on_thickness_value_changed(value: int) -> void:
|
||||||
_thickness = value
|
_thickness = value
|
||||||
update_indicator()
|
update_indicator()
|
||||||
update_config()
|
update_config()
|
||||||
save_config()
|
save_config()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_fill_checkbox_toggled(toggled_on: bool) -> void:
|
||||||
|
_fill = toggled_on
|
||||||
|
update_config()
|
||||||
|
save_config()
|
||||||
|
|
||||||
|
|
||||||
func update_indicator() -> void:
|
func update_indicator() -> void:
|
||||||
var bitmap := BitMap.new()
|
var bitmap := BitMap.new()
|
||||||
bitmap.create(Vector2i.ONE * _thickness)
|
bitmap.create(Vector2i.ONE * _thickness)
|
||||||
|
@ -142,6 +149,15 @@ func _draw_shape() -> void:
|
||||||
_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_tool(point)
|
||||||
|
if _fill:
|
||||||
|
var v := Vector2i()
|
||||||
|
var image_size := Global.current_project.size
|
||||||
|
for x in image_size.x:
|
||||||
|
v.x = x
|
||||||
|
for y in image_size.y:
|
||||||
|
v.y = y
|
||||||
|
if Geometry2D.is_point_in_polygon(v, points):
|
||||||
|
draw_tool(v)
|
||||||
_curve.clear_points()
|
_curve.clear_points()
|
||||||
_drawing = false
|
_drawing = false
|
||||||
commit_undo()
|
commit_undo()
|
||||||
|
|
|
@ -20,6 +20,12 @@ suffix = "px"
|
||||||
global_increment_action = "brush_size_increment"
|
global_increment_action = "brush_size_increment"
|
||||||
global_decrement_action = "brush_size_decrement"
|
global_decrement_action = "brush_size_decrement"
|
||||||
|
|
||||||
|
[node name="FillCheckbox" type="CheckBox" parent="." index="3"]
|
||||||
|
layout_mode = 2
|
||||||
|
tooltip_text = "Fills the drawn shape with color, instead of drawing a hollow shape"
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
text = "Fill Shape"
|
||||||
|
|
||||||
[node name="Rotate90" parent="RotationOptions/Rotate" index="0"]
|
[node name="Rotate90" parent="RotationOptions/Rotate" index="0"]
|
||||||
button_group = SubResource("ButtonGroup_ko8wf")
|
button_group = SubResource("ButtonGroup_ko8wf")
|
||||||
|
|
||||||
|
@ -29,11 +35,12 @@ button_group = SubResource("ButtonGroup_ko8wf")
|
||||||
[node name="Rotate270" parent="RotationOptions/Rotate" index="2"]
|
[node name="Rotate270" parent="RotationOptions/Rotate" index="2"]
|
||||||
button_group = SubResource("ButtonGroup_ko8wf")
|
button_group = SubResource("ButtonGroup_ko8wf")
|
||||||
|
|
||||||
[node name="Brush" parent="." index="4"]
|
[node name="Brush" parent="." index="5"]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="DoubleClickTimer" type="Timer" parent="." index="6"]
|
[node name="DoubleClickTimer" type="Timer" parent="." index="7"]
|
||||||
wait_time = 0.2
|
wait_time = 0.2
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[connection signal="value_changed" from="ThicknessSlider" to="." method="_on_Thickness_value_changed"]
|
[connection signal="value_changed" from="ThicknessSlider" to="." method="_on_thickness_value_changed"]
|
||||||
|
[connection signal="toggled" from="FillCheckbox" to="." method="_on_fill_checkbox_toggled"]
|
||||||
|
|
Loading…
Reference in a new issue