class_name TypedLetter
extends Control

onready var label: Label = $Label

var letter_size := Vector2.ZERO

func _ready() ->void:
	pass

func get_width() -> float:
	return letter_size.x

func add_label(text: String) -> void:
	label.text = text
	letter_size = label.get_font("font").get_string_size(label.text)
	label.rect_pivot_offset = letter_size / 2
	$AnimationPlayer.play("spawn")
	$AudioStreamPlayer.pitch_scale = 0.7 + randf()
	$AudioStreamPlayer.play()

func delete_label() -> void:
	$AudioStreamPlayer2.play()
	$AnimationPlayer.play("delete")

func on_delete() -> void:
	queue_free()
