Drawing and then saving a png file?

:bust_in_silhouette: Reply From: chugwig

Here’s a way to record a viewport (the root viewport by default) to a PNG file. From there it’s just about putting everything in the scene with the appropriate blending modes.

extends Node


export(NodePath) var viewport_path = null


onready var target_viewport = get_node(viewport_path) if viewport_path else get_tree().root.get_viewport()


func save_to(path):
	var img = target_viewport.get_texture().get_data()
	img.flip_y()
	return img.save_png(path)