I do not think there is a way to use the drawing functions outside of the _draw
method of the node. However, you could try storing the data in something like an array or dictionary, and have the functions populate this data. Something like this (untested, simple example):
static functions
static func draw_line(data_array):
data_array.append(["Line", Vector2(), Vector2(100, 100), Color.white])
static func draw_circle(data_array):
data_array.append(["Circle", Vector2(-40, -40), 200, Color.green])
Then in the node that is calling these functions:
func _draw():
var array_of_drawing_data = [];
draw_line(array_of_drawing_data )
draw_circle(array_of_drawing_data )
for drawing_data in array_of_drawing_data:
if drawing_data[0] == "Line":
draw_line(drawing_data[1], drawing_data[2], drawing_data[3])
elif drawing_data[0] == "Circle":
draw_circle(drawing_data[1], drawing_data[2], drawing_data[3])
It is not perhaps the most ideal, but it should allow for populating drawing data externally that only requires some minimal processing to draw in the _draw
function of the node that is calling the static functions.