mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Further improvements to Dynamics (#828)
* Image bruch now obeys dynamics as well * Added a signal that resets dynamics * formatting * change uncheck.png * added preview for pressure * Added the requested changes
This commit is contained in:
parent
eee4e50fd3
commit
e88ba2cb73
Binary file not shown.
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 131 B |
|
@ -165,6 +165,7 @@ onready var tabs: Tabs = control.find_node("Tabs")
|
|||
onready var main_viewport: ViewportContainer = control.find_node("ViewportContainer")
|
||||
onready var second_viewport: ViewportContainer = control.find_node("Second Canvas")
|
||||
onready var canvas_preview_container: Container = control.find_node("Canvas Preview")
|
||||
onready var global_tool_options: PanelContainer = control.find_node("Global Tool Options")
|
||||
onready var small_preview_viewport: ViewportContainer = canvas_preview_container.find_node(
|
||||
"PreviewViewportContainer"
|
||||
)
|
||||
|
|
|
@ -6,6 +6,7 @@ var _brush_size_dynamics := 1
|
|||
var _cache_limit := 3
|
||||
var _brush_interpolate := 0
|
||||
var _brush_image := Image.new()
|
||||
var _orignal_brush_image := Image.new() # contains the orignal _brush_image (whithout resizing)
|
||||
var _brush_texture := ImageTexture.new()
|
||||
var _strength := 1.0
|
||||
var _picking_color := false
|
||||
|
@ -31,6 +32,7 @@ var _circle_tool_shortcut: PoolVector2Array
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.global_tool_options.connect("dynamics_changed", self, "_reset_dynamics")
|
||||
Tools.connect("color_changed", self, "_on_Color_changed")
|
||||
Global.brushes_popup.connect("brush_removed", self, "_on_Brush_removed")
|
||||
|
||||
|
@ -64,6 +66,17 @@ func _on_BrushSize_value_changed(value: float) -> void:
|
|||
if _brush_size != int(value):
|
||||
_brush_size = int(value)
|
||||
_brush_size_dynamics = _brush_size
|
||||
if Tools.dynamics_size != Tools.Dynamics.NONE:
|
||||
_brush_size_dynamics = Tools.brush_size_min
|
||||
_cache_limit = (_brush_size * _brush_size) * 3 # This equation seems the best match
|
||||
update_config()
|
||||
save_config()
|
||||
|
||||
|
||||
func _reset_dynamics() -> void:
|
||||
_brush_size_dynamics = _brush_size
|
||||
if Tools.dynamics_size != Tools.Dynamics.NONE:
|
||||
_brush_size_dynamics = Tools.brush_size_min
|
||||
_cache_limit = (_brush_size * _brush_size) * 3 # This equation seems the best match
|
||||
update_config()
|
||||
save_config()
|
||||
|
@ -101,6 +114,8 @@ func set_config(config: Dictionary) -> void:
|
|||
_brush = Global.brushes_popup.get_brush(type, index)
|
||||
_brush_size = config.get("brush_size", _brush_size)
|
||||
_brush_size_dynamics = _brush_size
|
||||
if Tools.dynamics_size != Tools.Dynamics.NONE:
|
||||
_brush_size_dynamics = Tools.brush_size_min
|
||||
_brush_interpolate = config.get("brush_interpolate", _brush_interpolate)
|
||||
|
||||
|
||||
|
@ -125,10 +140,11 @@ func update_brush() -> void:
|
|||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
||||
$Brush/BrushSize.suffix = "00 %" # Use a different size convention on images
|
||||
if _brush.random.size() <= 1:
|
||||
_brush_image = _create_blended_brush_image(_brush.image)
|
||||
_orignal_brush_image = _brush.image
|
||||
else:
|
||||
var random := randi() % _brush.random.size()
|
||||
_brush_image = _create_blended_brush_image(_brush.random[random])
|
||||
_orignal_brush_image = _brush.random[random]
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
_brush_texture.create_from_image(_brush_image, 0)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
|
@ -213,10 +229,15 @@ func draw_tool(position: Vector2) -> void:
|
|||
|
||||
func draw_end(position: Vector2) -> void:
|
||||
.draw_end(position)
|
||||
if Tools.dynamics_size == Tools.Dynamics.PRESSURE:
|
||||
_brush_size_dynamics = Tools.brush_size_min
|
||||
else:
|
||||
_brush_size_dynamics = _brush_size
|
||||
if Tools.dynamics_size != Tools.Dynamics.NONE:
|
||||
_brush_size_dynamics = Tools.brush_size_min
|
||||
match _brush.type:
|
||||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
_brush_texture.create_from_image(_brush_image, 0)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
_indicator = _create_brush_indicator()
|
||||
_polylines = _create_polylines(_indicator)
|
||||
|
||||
|
@ -238,19 +259,25 @@ func _prepare_tool() -> void:
|
|||
_drawer.horizontal_mirror = Tools.horizontal_mirror
|
||||
_drawer.vertical_mirror = Tools.vertical_mirror
|
||||
_drawer.color_op.strength = strength
|
||||
_indicator = _create_brush_indicator()
|
||||
_polylines = _create_polylines(_indicator)
|
||||
# Memorize current project
|
||||
_stroke_project = Global.current_project
|
||||
# Memorize the frame/layer we are drawing on rather than fetching it on every pixel
|
||||
_stroke_images = _get_selected_draw_images()
|
||||
# This may prevent a few tests when setting pixels
|
||||
_indicator = _create_brush_indicator()
|
||||
_polylines = _create_polylines(_indicator)
|
||||
_is_mask_size_zero = _mask.size() == 0
|
||||
match _brush.type:
|
||||
Brushes.CIRCLE:
|
||||
_prepare_circle_tool(false)
|
||||
Brushes.FILLED_CIRCLE:
|
||||
_prepare_circle_tool(true)
|
||||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
||||
# save _brush_image for safe keeping
|
||||
_brush_image = _create_blended_brush_image(_orignal_brush_image)
|
||||
_brush_texture.create_from_image(_brush_image, 0)
|
||||
update_mirror_brush()
|
||||
_stroke_dimensions = _brush_image.get_size()
|
||||
|
||||
|
||||
func _prepare_circle_tool(fill: bool) -> void:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extends PanelContainer
|
||||
|
||||
signal dynamics_changed
|
||||
|
||||
enum { ALPHA, SIZE }
|
||||
|
||||
var alpha_last_pressed: BaseButton = null
|
||||
|
@ -16,6 +18,8 @@ onready var alpha_pressure_button: Button = $"%AlphaPressureButton"
|
|||
onready var alpha_velocity_button: Button = $"%AlphaVelocityButton"
|
||||
onready var size_pressure_button: Button = $"%SizePressureButton"
|
||||
onready var size_velocity_button: Button = $"%SizeVelocityButton"
|
||||
onready var pressure_preview: ProgressBar = $"%PressurePreview"
|
||||
onready var velocity_preview: ProgressBar = $"%VelocityPreview"
|
||||
onready var alpha_group: ButtonGroup = alpha_pressure_button.group
|
||||
onready var size_group: ButtonGroup = size_pressure_button.group
|
||||
|
||||
|
@ -53,6 +57,14 @@ func _ready() -> void:
|
|||
)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
pressure_preview.value = 0
|
||||
velocity_preview.value = 0
|
||||
if event is InputEventMouseMotion:
|
||||
pressure_preview.value = event.pressure
|
||||
velocity_preview.value = event.speed.length() / Tools.mouse_velocity_max
|
||||
|
||||
|
||||
func _on_resized() -> void:
|
||||
var tool_panel_size := rect_size
|
||||
var column_n := tool_panel_size.x / 36.5
|
||||
|
@ -146,6 +158,7 @@ func _on_Dynamics_toggled(
|
|||
if !button.pressed:
|
||||
file_name = "uncheck.png"
|
||||
Global.change_button_texturerect(texture_button, file_name)
|
||||
emit_signal("dynamics_changed")
|
||||
|
||||
|
||||
func _set_last_pressed_button(prop: int, value: BaseButton) -> void:
|
||||
|
@ -168,15 +181,19 @@ func _on_ThresholdVelocity_updated(value_1, value_2) -> void:
|
|||
|
||||
func _on_AlphaMin_value_changed(value: float) -> void:
|
||||
Tools.alpha_min = value
|
||||
emit_signal("dynamics_changed")
|
||||
|
||||
|
||||
func _on_AlphaMax_value_changed(value: float) -> void:
|
||||
Tools.alpha_max = value
|
||||
emit_signal("dynamics_changed")
|
||||
|
||||
|
||||
func _on_SizeMin_value_changed(value: float) -> void:
|
||||
Tools.brush_size_min = int(value)
|
||||
emit_signal("dynamics_changed")
|
||||
|
||||
|
||||
func _on_SizeMax_value_changed(value: float) -> void:
|
||||
Tools.brush_size_max = int(value)
|
||||
emit_signal("dynamics_changed")
|
||||
|
|
|
@ -301,7 +301,7 @@ stretch_margin_top = 3
|
|||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource( 5 )
|
||||
prefix = "Min"
|
||||
prefix = "Start"
|
||||
snap_step = 0.1
|
||||
|
||||
[node name="AlphaMax" type="TextureProgress" parent="DynamicsPanel/VBoxContainer/LimitContainer"]
|
||||
|
@ -320,7 +320,7 @@ stretch_margin_top = 3
|
|||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource( 5 )
|
||||
prefix = "Max"
|
||||
prefix = "End"
|
||||
snap_step = 0.1
|
||||
|
||||
[node name="SizeLabel" type="Label" parent="DynamicsPanel/VBoxContainer/LimitContainer"]
|
||||
|
@ -347,7 +347,7 @@ stretch_margin_top = 3
|
|||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource( 5 )
|
||||
prefix = "Min"
|
||||
prefix = "Start"
|
||||
|
||||
[node name="SizeMax" type="TextureProgress" parent="DynamicsPanel/VBoxContainer/LimitContainer"]
|
||||
margin_left = 171.0
|
||||
|
@ -366,7 +366,7 @@ stretch_margin_top = 3
|
|||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource( 5 )
|
||||
prefix = "Max"
|
||||
prefix = "End"
|
||||
|
||||
[node name="ThresholdsHeader" type="HBoxContainer" parent="DynamicsPanel/VBoxContainer"]
|
||||
margin_top = 126.0
|
||||
|
@ -412,6 +412,16 @@ margin_right = 192.0
|
|||
margin_bottom = 30.0
|
||||
texture = SubResource( 4 )
|
||||
|
||||
[node name="PressurePreview" type="ProgressBar" parent="DynamicsPanel/VBoxContainer/ThresholdContainer/ThresholdPressure/TextureRect" index="0"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color( 1, 1, 1, 0.294118 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
value = 0.497
|
||||
percent_visible = false
|
||||
|
||||
[node name="ThresholdVelocityLabel" type="Label" parent="DynamicsPanel/VBoxContainer/ThresholdContainer"]
|
||||
margin_top = 42.0
|
||||
margin_right = 56.0
|
||||
|
@ -433,6 +443,15 @@ margin_right = 192.0
|
|||
margin_bottom = 30.0
|
||||
texture = SubResource( 5 )
|
||||
|
||||
[node name="VelocityPreview" type="ProgressBar" parent="DynamicsPanel/VBoxContainer/ThresholdContainer/ThresholdVelocity/TextureRect" index="0"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color( 1, 1, 1, 0.294118 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
percent_visible = false
|
||||
|
||||
[connection signal="resized" from="." to="." method="_on_resized"]
|
||||
[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/Horizontal" to="." method="_on_Horizontal_toggled"]
|
||||
[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/Vertical" to="." method="_on_Vertical_toggled"]
|
||||
|
|
Loading…
Reference in a new issue