@tool
class_name Arc extends Control

const BASE_POINTS := 64

@export_range(-360, 360, 0.001, "radians") var arc_start := 0.1:
	set(value):
		arc_start = value
		queue_redraw()
@export_range(-360, 360, 0.001, "radians") var arc_end := TAU:
	set(value):
		arc_end = value
		queue_redraw()
@export var width := 1.0:
	set(value):
		width = value
		queue_redraw()
@export var antialiased := true:
	set(value):
		antialiased = value
		queue_redraw()
@export var color: Color:
	set(value):
		color = value
		queue_redraw()


func _draw() -> void:
	var radius: float = minf(size.x, size.y) / 2.0
	var width_buffer: float = floor(width / 2.0)
	var point_count: int = int(BASE_POINTS * (arc_end - arc_start) / TAU)
	draw_arc(
		Vector2(radius, radius),
		radius - width_buffer,
		arc_start,
		arc_end,
		point_count,
		color,
		width,
		antialiased
	)
