diff --git a/docs/changelog.md b/docs/changelog.md index 8a4bc7f2..1dd3d9bc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Setting to disable pressure sensitivity and always draw with a constant brush width - Quit shortcut (CTRL+Q by default) +- Alternative way to pan the canvas by holding `SPACE` and moving the mouse +- Brush stroke stabilizer/smoothing - Translations: Ukrainian, Arabic ### Fixed diff --git a/lorien/Assets/I18n/en.txt b/lorien/Assets/I18n/en.txt index 8347a7b1..7a75ef3c 100644 --- a/lorien/Assets/I18n/en.txt +++ b/lorien/Assets/I18n/en.txt @@ -62,7 +62,8 @@ SETTINGS_APPEARANCE Appearance SETTINGS_RENDERING Rendering SETTINGS_KEYBINDINGS Keybindings SETTINGS_PRESSURE_SENSITIVITY Pressure Sensitivity -SETTINGS_CONSTANT_PRESSURE Constant Pressure? +SETTINGS_CONSTANT_PRESSURE Constant Pressure +SETTINGS_STABILIZER_STRENGTH Stabilizer Strength SETTINGS_BRUSH_SIZE Default Brush Size SETTINGS_PROJECT_FOLDER Default save/load folder SETTINGS_GRID_SIZE Grid Size diff --git a/lorien/Config.gd b/lorien/Config.gd index 2f4f87ee..efd18078 100644 --- a/lorien/Config.gd +++ b/lorien/Config.gd @@ -25,3 +25,4 @@ const DEFAULT_UI_SCALE := 1.0 const DEFAULT_GRID_PATTERN := Types.GridPattern.DOTS const DEFAULT_GRID_SIZE := 25.0 const DEFAULT_TOOL_PRESSURE := 0.5 +const DEFAULT_STABILIZER_STRENGTH := 0.5 diff --git a/lorien/InfiniteCanvas/Tools/BrushTool.gd b/lorien/InfiniteCanvas/Tools/BrushTool.gd index a15a03a6..bd5c84a1 100644 --- a/lorien/InfiniteCanvas/Tools/BrushTool.gd +++ b/lorien/InfiniteCanvas/Tools/BrushTool.gd @@ -39,24 +39,30 @@ func _process(delta: float) -> void: if performing_stroke: var pos := _cursor.global_position - # Smoothing var diff := pos.distance_squared_to(_last_accepted_position) if diff <= MOVEMENT_THRESHOLD || _current_pressure <= MIN_PRESSURE: return + + # Stabilizer smoothing + var stabilizer_strength: float = Settings.get_general_value( + Settings.GENERAL_STABILIZER_STRENGTH, Config.DEFAULT_STABILIZER_STRENGTH + ) var points := get_current_brush_stroke().points if points.size() > 3: var p3 := points[-3] var p2 := points[-2] var p1 := points[-1] - # TODO: expose the smoothing factor in the settings - pos = Utils.cubic_bezier(p3, p2, p1, pos, 0.75) + # t is in [0.5, 1.0] interval depending on stabilizer settings + var t := 0.5 + (1.0 - stabilizer_strength) * 0.5 + pos = Utils.cubic_bezier(p3, p2, p1, pos, t) + + # Pressure var sensitivity: float = Settings.get_general_value( Settings.GENERAL_PRESSURE_SENSITIVITY, Config.DEFAULT_PRESSURE_SENSITIVITY ) - # Pressure var point_pressure := pressure_curve.sample(_current_pressure) * sensitivity if _first_point: point_pressure *= 1.4 diff --git a/lorien/Misc/Settings.gd b/lorien/Misc/Settings.gd index 07117f78..5634e77e 100644 --- a/lorien/Misc/Settings.gd +++ b/lorien/Misc/Settings.gd @@ -4,6 +4,7 @@ extends Node const GENERAL_SECTION := "general" const GENERAL_PRESSURE_SENSITIVITY := "pressure_sensitvity" const GENERAL_CONSTANT_PRESSURE := "constant_pressure" +const GENERAL_STABILIZER_STRENGTH := "stabilizer_strength" const GENERAL_DEFAULT_BRUSH_SIZE := "default_brush_size" const GENERAL_DEFAULT_PROJECT_DIR := "default_project_dir" const GENERAL_LANGUAGE := "language" diff --git a/lorien/UI/Dialogs/SettingsDialog.gd b/lorien/UI/Dialogs/SettingsDialog.gd index b514766e..8d1b571d 100644 --- a/lorien/UI/Dialogs/SettingsDialog.gd +++ b/lorien/UI/Dialogs/SettingsDialog.gd @@ -39,6 +39,7 @@ signal constant_pressure_changed(state: bool) @onready var _constant_pressure: CheckBox = %ConstantPressure @onready var _brush_size: SpinBox = %DefaultBrushSize @onready var _tool_pressure: SpinBox = %DefaultToolPressure +@onready var _stabilizer_strength: SpinBox = %StabilizerStrength @onready var _project_dir: LineEdit = %DefaultProjectDir @onready var _language: OptionButton = %Language @onready var _theme: OptionButton = %Theme @@ -61,6 +62,7 @@ func _ready() -> void: _pressure_sensitivity.value_changed.connect(_on_pressure_sensitivity_changed) _constant_pressure.toggled.connect(_on_constant_pressure_toggled) + _stabilizer_strength.value_changed.connect(_on_stabilizer_strength_changed) _brush_size.value_changed.connect(_on_default_brush_size_changed) _tool_pressure.value_changed.connect(_on_default_tool_pressure_changed) _project_dir.text_changed.connect(_on_default_project_dir_changed) @@ -88,6 +90,7 @@ func _set_values() -> void: var tool_pressure: float = Settings.get_general_value(Settings.GENERAL_TOOL_PRESSURE, Config.DEFAULT_TOOL_PRESSURE) var pressure_sensitivity: float = Settings.get_general_value(Settings.GENERAL_PRESSURE_SENSITIVITY, Config.DEFAULT_PRESSURE_SENSITIVITY) var constant_pressure: bool = Settings.get_general_value(Settings.GENERAL_CONSTANT_PRESSURE, Config.DEFAULT_CONSTANT_PRESSURE) + var stabilizer_strength: float = Settings.get_general_value(Settings.GENERAL_STABILIZER_STRENGTH, Config.DEFAULT_STABILIZER_STRENGTH) var canvas_color: Color = Settings.get_appearance_value(Settings.APPEARANCE_CANVAS_COLOR, Config.DEFAULT_CANVAS_COLOR) var ui_theme: Types.UITheme = Settings.get_appearance_value(Settings.APPEARANCE_THEME, Types.UITheme.DARK) @@ -117,6 +120,7 @@ func _set_values() -> void: _constant_pressure.button_pressed = constant_pressure _pressure_sensitivity.value = pressure_sensitivity + _stabilizer_strength.value = stabilizer_strength _brush_size.value = brush_size _tool_pressure.value = tool_pressure _canvas_color.color = canvas_color @@ -295,6 +299,10 @@ func _on_ui_scale_changed(value: float) -> void: func _on_default_tool_pressure_changed(value: float) -> void: Settings.set_general_value(Settings.GENERAL_TOOL_PRESSURE, value) +# ------------------------------------------------------------------------------------------------- +func _on_stabilizer_strength_changed(value: float) -> void: + Settings.set_general_value(Settings.GENERAL_STABILIZER_STRENGTH, value) + # ------------------------------------------------------------------------------------------------- func _on_constant_pressure_toggled(button_pressed: bool) -> void: Settings.set_general_value(Settings.GENERAL_CONSTANT_PRESSURE, button_pressed) diff --git a/lorien/UI/Dialogs/SettingsDialog.tscn b/lorien/UI/Dialogs/SettingsDialog.tscn index 4facba6f..8a6dbeb2 100644 --- a/lorien/UI/Dialogs/SettingsDialog.tscn +++ b/lorien/UI/Dialogs/SettingsDialog.tscn @@ -55,7 +55,6 @@ layout_mode = 2 [node name="GeneralContainer" type="ScrollContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"] unique_name_in_owner = true -visible = false layout_mode = 2 size_flags_vertical = 3 @@ -141,6 +140,25 @@ max_value = 1.0 step = 0.05 value = 1.0 +[node name="StabilizerStrength" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer/StabilizerStrength"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 6 +text = "SETTINGS_STABILIZER_STRENGTH" + +[node name="StabilizerStrength" type="SpinBox" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer/StabilizerStrength"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +max_value = 1.0 +step = 0.05 +value = 1.0 + [node name="DefaultProjectDir" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 @@ -390,6 +408,7 @@ allow_greater = true [node name="KeybindingsContainer" type="ScrollContainer" parent="VBoxContainer/MarginContainer/VBoxContainer"] unique_name_in_owner = true +visible = false layout_mode = 2 size_flags_vertical = 3