@tool class_name ContiguousBar extends Control @onready var fill: NinePatchRect = $Fill @export var value: int: set(v): value = v _refresh() @export var max_value: int: set(v): max_value = v _refresh() func _ready() -> void: _refresh() func _refresh() -> void: if fill == null: return var ratio := 0.0 if max_value > 0: ratio = clampf(float(value) / float(max_value), 0.0, 1.0) fill.anchor_top = 0.0 fill.anchor_bottom = 1.0 fill.anchor_right = 1.0 fill.anchor_left = 1.0 - ratio fill.offset_top = 1.0 fill.offset_bottom = -1.0 fill.offset_right = -1.0 fill.offset_left = 2.0 * ratio - 1.0