From 873e2b8e9e4e55f4047df4a30c2cd77e97474279 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 8 Jul 2021 21:48:47 +0300 Subject: [PATCH] The indicator's size of the shape tools should now change depending on the tool's thickness --- src/Tools/LineTool.gd | 15 +++++++++++++++ src/Tools/ShapeDrawer.gd | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Tools/LineTool.gd b/src/Tools/LineTool.gd index 3c2c1fbd5..08dbe6f0c 100644 --- a/src/Tools/LineTool.gd +++ b/src/Tools/LineTool.gd @@ -12,14 +12,29 @@ var _thickness := 1 func _init() -> void: _drawer.color_op = Drawer.ColorOp.new() + update_indicator() + + +func update_brush() -> void: + pass func _on_Thickness_value_changed(value: int) -> void: _thickness = value + + update_indicator() update_config() save_config() +func update_indicator() -> void: + var bitmap := BitMap.new() + bitmap.create(Vector2.ONE * _thickness) + bitmap.set_bit_rect(Rect2(Vector2.ZERO, Vector2.ONE * _thickness), true) + _indicator = bitmap + _polylines = _create_polylines(_indicator) + + func get_config() -> Dictionary: var config := .get_config() config["thickness"] = _thickness diff --git a/src/Tools/ShapeDrawer.gd b/src/Tools/ShapeDrawer.gd index fb5640ce9..6e8c89839 100644 --- a/src/Tools/ShapeDrawer.gd +++ b/src/Tools/ShapeDrawer.gd @@ -12,14 +12,29 @@ var _thickness := 1 func _init() -> void: _drawer.color_op = Drawer.ColorOp.new() + update_indicator() + + +func update_brush() -> void: + pass func _on_Thickness_value_changed(value: int) -> void: _thickness = value + + update_indicator() update_config() save_config() +func update_indicator() -> void: + var bitmap := BitMap.new() + bitmap.create(Vector2.ONE * _thickness) + bitmap.set_bit_rect(Rect2(Vector2.ZERO, Vector2.ONE * _thickness), true) + _indicator = bitmap + _polylines = _create_polylines(_indicator) + + func _on_FillCheckbox_toggled(button_pressed: bool) -> void: _fill = button_pressed update_config()