Added lighten/darken option and amount for the LightenDarken tool

You don't use Ctrl anymore to switch between Lighten and Darken
This commit is contained in:
OverloadedOrama 2019-12-04 01:01:37 +02:00
parent 700f287edc
commit dd60f0fc7e
4 changed files with 119 additions and 7 deletions

View file

@ -84,14 +84,21 @@ func _process(delta) -> void:
var current_mouse_button := "None"
var current_action := "None"
var fill_area := 0 #For the bucket tool
#For the LightenDarken tool
var ld := 0
var ld_amount := 0.1
if Input.is_mouse_button_pressed(BUTTON_LEFT):
current_mouse_button = "left_mouse"
current_action = Global.current_left_tool
fill_area = Global.left_fill_area
ld = Global.left_ld
ld_amount = Global.left_ld_amount
elif Input.is_mouse_button_pressed(BUTTON_RIGHT):
current_mouse_button = "right_mouse"
current_action = Global.current_right_tool
fill_area = Global.right_fill_area
ld = Global.right_ld
ld_amount = Global.right_ld_amount
if Global.current_frame == frame:
if !mouse_in_canvas:
@ -182,10 +189,11 @@ func _process(delta) -> void:
"LightenDarken":
if mouse_in_canvas && Global.can_draw && Global.has_focus && Global.current_frame == frame:
var pixel_color : Color = layers[current_layer_index][0].get_pixelv(mouse_pos)
var amount := 0.1
var color_changed := pixel_color.lightened(amount)
if Input.is_key_pressed(KEY_CONTROL):
color_changed = pixel_color.darkened(amount)
var color_changed : Color
if ld == 0: #Lighten
color_changed = pixel_color.lightened(ld_amount)
else: #Darken
color_changed = pixel_color.darkened(ld_amount)
pencil_and_eraser(mouse_pos, color_changed, current_mouse_button, current_action)
"RectSelect":
#Check SelectionRectangle.gd for more code on Rectangle Selection

View file

@ -75,6 +75,9 @@ var right_interpolate_slider : HSlider
var left_fill_area_container : Container
var right_fill_area_container : Container
var left_ld_container : Container
var right_ld_container : Container
var left_mirror_container : Container
var right_mirror_container : Container
@ -110,9 +113,16 @@ var brushes_popup : Popup
var file_brush_container : GridContainer
var project_brush_container : GridContainer
#0 for area of same color, 1 for all pixels of the same color
var left_fill_area := 0
var right_fill_area := 0
#0 for lighten, 1 for darken
var left_ld := 0
var right_ld := 0
var left_ld_amount := 0.1
var right_ld_amount := 0.1
# warning-ignore:unused_class_variable
var left_horizontal_mirror := false
# warning-ignore:unused_class_variable
@ -187,6 +197,9 @@ func _ready() -> void:
left_fill_area_container = find_node_by_name(left_tool_options_container, "LeftFillArea")
right_fill_area_container = find_node_by_name(right_tool_options_container, "RightFillArea")
left_ld_container = find_node_by_name(left_tool_options_container, "LeftLDOptions")
right_ld_container = find_node_by_name(right_tool_options_container, "RightLDOptions")
left_mirror_container = find_node_by_name(left_tool_options_container, "LeftMirroring")
right_mirror_container = find_node_by_name(right_tool_options_container, "RightMirroring")

View file

@ -618,6 +618,7 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
Global.left_mirror_container.visible = true
elif current_action == "LightenDarken":
Global.left_brush_size_container.visible = true
Global.left_ld_container.visible = true
Global.left_mirror_container.visible = true
elif (mouse_press && Input.is_action_just_released("right_mouse")) || (!mouse_press && !key_for_left):
@ -642,6 +643,7 @@ func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_le
Global.right_mirror_container.visible = true
elif current_action == "LightenDarken":
Global.right_brush_size_container.visible = true
Global.right_ld_container.visible = true
Global.right_mirror_container.visible = true
for t in tools:
@ -930,6 +932,16 @@ func _on_LeftFillAreaOptions_item_selected(ID : int) -> void:
func _on_RightFillAreaOptions_item_selected(ID : int) -> void:
Global.right_fill_area = ID
func _on_LeftLightenDarken_item_selected(ID : int) -> void:
Global.left_ld = ID
func _on_LeftLDAmountSpinbox_value_changed(value : float) -> void:
Global.left_ld_amount = value
func _on_RightLightenDarken_item_selected(ID : int) -> void:
Global.right_ld = ID
func _on_RightLDAmountSpinbox_value_changed(value : float) -> void:
Global.right_ld_amount = value
func _on_LeftHorizontalMirroring_toggled(button_pressed) -> void:
Global.left_horizontal_mirror = button_pressed
func _on_LeftVerticalMirroring_toggled(button_pressed) -> void: