@tool
extends Node3D

const SIZE = 5
enum Direction {UP, RIGHT, DOWN, LEFT}
var sequence = []

var arrow = preload("res://Images/arrow.png")

func _ready():
	randomize()

	arrow.convert(Image.FORMAT_RG8)
	var painting = Image.create(128*SIZE, 128*SIZE, false, Image.FORMAT_RG8)
	var painting_em = Image.create(128*SIZE, 128*SIZE, false, Image.FORMAT_RG8)

	for x in range(SIZE):
		for y in range(SIZE):
			var dir = randi() % 4
			for i in range(dir):
				arrow.rotate_90(0)
			painting.blit_rect(arrow, arrow.get_used_rect() ,Vector2i(x*128, y*128))
			if randi() % SIZE == 0:
				painting_em.blit_rect(arrow, arrow.get_used_rect() ,Vector2i(x*128, y*128))
				sequence.append(dir)
			for i in range(4-dir):
				arrow.rotate_90(0)

	var texture = ImageTexture.create_from_image(painting)
	$Canvas.get_surface_override_material(0).albedo_texture = texture
	var texture_em = ImageTexture.create_from_image(painting_em)
	$Canvas.get_surface_override_material(0).emission_texture = texture_em
