mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Optimize shape drawing
Shape previews also need to be optimized somehow, including some of the selection tool's previews
This commit is contained in:
parent
c2fc70e436
commit
fdc8c05f07
|
@ -69,12 +69,14 @@ func set_pixel(image: Image, position: Vector2i, color: Color, ignore_mirroring
|
|||
var project := Global.current_project
|
||||
if not Tools.check_alpha_lock(image, position):
|
||||
drawers[0].set_pixel(image, position, color, color_op)
|
||||
SteamManager.set_achievement("ACH_FIRST_PIXEL")
|
||||
if ignore_mirroring:
|
||||
return
|
||||
if not Tools.horizontal_mirror and not Tools.vertical_mirror:
|
||||
return
|
||||
# Handle mirroring
|
||||
var mirrored_positions := Tools.get_mirrored_positions(position, project)
|
||||
for i in mirrored_positions.size():
|
||||
var mirror_pos := mirrored_positions[i]
|
||||
if project.can_pixel_get_drawn(mirror_pos) && not Tools.check_alpha_lock(image, mirror_pos):
|
||||
drawers[i + 1].set_pixel(image, mirror_pos, color, color_op)
|
||||
SteamManager.set_achievement("ACH_FIRST_PIXEL")
|
||||
|
|
|
@ -179,11 +179,16 @@ func _draw_shape(origin: Vector2i, dest: Vector2i) -> void:
|
|||
var rect := _get_result_rect(origin, dest)
|
||||
var points := _get_points(rect.size)
|
||||
prepare_undo("Draw Shape")
|
||||
var images := _get_selected_draw_images()
|
||||
var thickness_vector := rect.position - Vector2i((Vector2(0.5, 0.5) * (_thickness - 1)).ceil())
|
||||
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(rect.position + point - Vector2i((Vector2(0.5, 0.5) * (_thickness - 1)).ceil()))
|
||||
var draw_pos := point + thickness_vector
|
||||
if Global.current_project.can_pixel_get_drawn(draw_pos):
|
||||
for image in images:
|
||||
_drawer.set_pixel(image, draw_pos, tool_slot.color)
|
||||
|
||||
commit_undo()
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://n40lhf8hm7o1"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://n40lhf8hm7o1"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/Tools/BaseShapeDrawer.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="2"]
|
||||
[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"]
|
||||
|
||||
[sub_resource type="ButtonGroup" id="ButtonGroup_mvrqm"]
|
||||
resource_name = "rotate"
|
||||
allow_unpress = true
|
||||
|
||||
[node name="ToolOptions" instance=ExtResource("2")]
|
||||
script = ExtResource("1")
|
||||
|
||||
|
@ -22,7 +26,16 @@ tooltip_text = "Fills the drawn shape with color, instead of drawing a hollow sh
|
|||
mouse_default_cursor_shape = 2
|
||||
text = "Fill Shape"
|
||||
|
||||
[node name="Brush" parent="." index="4"]
|
||||
[node name="Rotate90" parent="RotationOptions/Rotate" index="0"]
|
||||
button_group = SubResource("ButtonGroup_mvrqm")
|
||||
|
||||
[node name="Rotate180" parent="RotationOptions/Rotate" index="1"]
|
||||
button_group = SubResource("ButtonGroup_mvrqm")
|
||||
|
||||
[node name="Rotate270" parent="RotationOptions/Rotate" index="2"]
|
||||
button_group = SubResource("ButtonGroup_mvrqm")
|
||||
|
||||
[node name="Brush" parent="." index="5"]
|
||||
visible = false
|
||||
|
||||
[connection signal="value_changed" from="ThicknessSlider" to="." method="_on_Thickness_value_changed"]
|
||||
|
|
Loading…
Reference in a new issue