From d02bb52d48b841044d7f3fde817678ee0803bb0f Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 1 Jul 2020 03:57:27 +0300 Subject: [PATCH] Removed some old code about pen pressure --- src/Autoload/DrawingAlgos.gd | 12 ++++++------ src/Autoload/HTML5FileExchange.gd | 15 ++++++++------- src/Canvas.gd | 9 ++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index 8ba98140c..0bd7dad76 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -84,7 +84,7 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt Global.canvas.sprite_changed_this_frame = true elif brush_type == Global.Brush_Types.CIRCLE || brush_type == Global.Brush_Types.FILLED_CIRCLE: - plot_circle(sprite, pos.x, pos.y, brush_size, color, brush_type == Global.Brush_Types.FILLED_CIRCLE) + plot_circle(sprite, pos.x, pos.y, brush_size, color, pen_pressure, brush_type == Global.Brush_Types.FILLED_CIRCLE) Global.canvas.sprite_changed_this_frame = true else: @@ -205,7 +205,7 @@ func fill_gaps(sprite : Image, end_pos : Vector2, start_pos : Vector2, color : C # Algorithm based on http://members.chello.at/easyfilter/bresenham.html -func plot_circle(sprite : Image, xm : int, ym : int, r : int, color : Color, fill := false) -> void: +func plot_circle(sprite : Image, xm : int, ym : int, r : int, color : Color, pen_pressure : float, fill := false) -> void: var radius := r # Used later for filling var x := -r var y := 0 @@ -215,10 +215,10 @@ func plot_circle(sprite : Image, xm : int, ym : int, r : int, color : Color, fil var quadrant_2 := Vector2(xm - y, ym - x) var quadrant_3 := Vector2(xm + x, ym - y) var quadrant_4 := Vector2(xm + y, ym + x) - draw_pixel_blended(sprite, quadrant_1, color, Global.canvas.pen_pressure) - draw_pixel_blended(sprite, quadrant_2, color, Global.canvas.pen_pressure) - draw_pixel_blended(sprite, quadrant_3, color, Global.canvas.pen_pressure) - draw_pixel_blended(sprite, quadrant_4, color, Global.canvas.pen_pressure) + draw_pixel_blended(sprite, quadrant_1, color, pen_pressure) + draw_pixel_blended(sprite, quadrant_2, color, pen_pressure) + draw_pixel_blended(sprite, quadrant_3, color, pen_pressure) + draw_pixel_blended(sprite, quadrant_4, color, pen_pressure) r = err if r <= y: diff --git a/src/Autoload/HTML5FileExchange.gd b/src/Autoload/HTML5FileExchange.gd index 8576178dd..81c113c63 100644 --- a/src/Autoload/HTML5FileExchange.gd +++ b/src/Autoload/HTML5FileExchange.gd @@ -14,6 +14,7 @@ func _notification(notification:int) -> void: if notification == MainLoop.NOTIFICATION_WM_FOCUS_IN: emit_signal("InFocus") + func _define_js() -> void: # Define JS script JavaScript.eval(""" @@ -57,23 +58,23 @@ func load_image() -> void: if OS.get_name() != "HTML5" or !OS.has_feature('JavaScript'): return - # Execute js function - JavaScript.eval("upload_image();", true) # opens prompt for choosing file + # Execute JS function + JavaScript.eval("upload_image();", true) # Opens prompt for choosing file - yield(self, "InFocus") # wait until js prompt is closed + yield(self, "InFocus") # Wait until JS prompt is closed - yield(get_tree().create_timer(0.5), "timeout") #give some time for async js data load + yield(get_tree().create_timer(0.5), "timeout") # Give some time for async JS data load - if JavaScript.eval("canceled;", true): # if File Dialog closed w/o file + if JavaScript.eval("canceled;", true): # If File Dialog closed w/o file return - # use data from png data + # Use data from png data var imageData while true: imageData = JavaScript.eval("fileData;", true) if imageData != null: break - yield(get_tree().create_timer(1.0), "timeout") # need more time to load data + yield(get_tree().create_timer(1.0), "timeout") # Need more time to load data var image_type = JavaScript.eval("fileType;", true) var image_name = JavaScript.eval("fileName;", true) diff --git a/src/Canvas.gd b/src/Canvas.gd index f9296935b..0fade434a 100644 --- a/src/Canvas.gd +++ b/src/Canvas.gd @@ -128,11 +128,10 @@ func _input(event : InputEvent) -> void: # Godot 3.2 and above only code if Engine.get_version_info().major == 3 && Engine.get_version_info().minor >= 2: if event is InputEventMouseMotion: - pen_pressure = event.pressure - - # To be removed once Godot 3.2.2 is out of beta - if event.pressure == 0.0: # Drawing with mouse - pen_pressure = 1 # This causes problems with tablets though + if Global.pressure_sensitivity_mode == Global.Pressure_Sensitivity.NONE: + pen_pressure = 1 + else: + pen_pressure = event.pressure sprite_changed_this_frame = false var mouse_pos := current_pixel