1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Removed some old code about pen pressure

This commit is contained in:
OverloadedOrama 2020-07-01 03:57:27 +03:00
parent 6e7b3610d0
commit d02bb52d48
3 changed files with 18 additions and 18 deletions

View file

@ -84,7 +84,7 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
Global.canvas.sprite_changed_this_frame = true Global.canvas.sprite_changed_this_frame = true
elif brush_type == Global.Brush_Types.CIRCLE || brush_type == Global.Brush_Types.FILLED_CIRCLE: 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 Global.canvas.sprite_changed_this_frame = true
else: 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 # 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 radius := r # Used later for filling
var x := -r var x := -r
var y := 0 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_2 := Vector2(xm - y, ym - x)
var quadrant_3 := Vector2(xm + x, ym - y) var quadrant_3 := Vector2(xm + x, ym - y)
var quadrant_4 := Vector2(xm + y, ym + x) var quadrant_4 := Vector2(xm + y, ym + x)
draw_pixel_blended(sprite, quadrant_1, color, Global.canvas.pen_pressure) draw_pixel_blended(sprite, quadrant_1, color, pen_pressure)
draw_pixel_blended(sprite, quadrant_2, color, Global.canvas.pen_pressure) draw_pixel_blended(sprite, quadrant_2, color, pen_pressure)
draw_pixel_blended(sprite, quadrant_3, color, Global.canvas.pen_pressure) draw_pixel_blended(sprite, quadrant_3, color, pen_pressure)
draw_pixel_blended(sprite, quadrant_4, color, Global.canvas.pen_pressure) draw_pixel_blended(sprite, quadrant_4, color, pen_pressure)
r = err r = err
if r <= y: if r <= y:

View file

@ -14,6 +14,7 @@ func _notification(notification:int) -> void:
if notification == MainLoop.NOTIFICATION_WM_FOCUS_IN: if notification == MainLoop.NOTIFICATION_WM_FOCUS_IN:
emit_signal("InFocus") emit_signal("InFocus")
func _define_js() -> void: func _define_js() -> void:
# Define JS script # Define JS script
JavaScript.eval(""" JavaScript.eval("""
@ -57,23 +58,23 @@ func load_image() -> void:
if OS.get_name() != "HTML5" or !OS.has_feature('JavaScript'): if OS.get_name() != "HTML5" or !OS.has_feature('JavaScript'):
return return
# Execute js function # Execute JS function
JavaScript.eval("upload_image();", true) # opens prompt for choosing file 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 return
# use data from png data # Use data from png data
var imageData var imageData
while true: while true:
imageData = JavaScript.eval("fileData;", true) imageData = JavaScript.eval("fileData;", true)
if imageData != null: if imageData != null:
break 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_type = JavaScript.eval("fileType;", true)
var image_name = JavaScript.eval("fileName;", true) var image_name = JavaScript.eval("fileName;", true)

View file

@ -128,11 +128,10 @@ func _input(event : InputEvent) -> void:
# Godot 3.2 and above only code # Godot 3.2 and above only code
if Engine.get_version_info().major == 3 && Engine.get_version_info().minor >= 2: if Engine.get_version_info().major == 3 && Engine.get_version_info().minor >= 2:
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
pen_pressure = event.pressure if Global.pressure_sensitivity_mode == Global.Pressure_Sensitivity.NONE:
pen_pressure = 1
# To be removed once Godot 3.2.2 is out of beta else:
if event.pressure == 0.0: # Drawing with mouse pen_pressure = event.pressure
pen_pressure = 1 # This causes problems with tablets though
sprite_changed_this_frame = false sprite_changed_this_frame = false
var mouse_pos := current_pixel var mouse_pos := current_pixel