Created
February 11, 2025 21:10
-
-
Save BrastenXBL/59ae598ebd4d583cd7f2f9a95cf78ad6 to your computer and use it in GitHub Desktop.
Patterned Colored Progress Bars for Godot 4.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=17 format=3] | |
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vq0ld"] | |
[sub_resource type="GDScript" id="GDScript_f68c0"] | |
script/source = "extends ProgressBar | |
@export_range(0.0,2.0) var value_rate = 0.5 | |
@export var value_color_high := Color.GREEN | |
@export var value_color_mid := Color.GOLD | |
@export var value_color_low := Color.CRIMSON | |
var _value_flip : bool | |
func _process(delta: float) -> void: | |
_anim_value() | |
_color_progress() | |
func _anim_value(): | |
value += -value_rate + 2.0 * value_rate * (_value_flip as int) | |
if value <= min_value or value >= max_value: | |
_value_flip = !_value_flip | |
func _color_progress(): | |
if value >= max_value * 0.7: | |
get(\"theme_override_styles/fill\").bg_color = value_color_high | |
elif value >= max_value * 0.4: | |
get(\"theme_override_styles/fill\").bg_color = value_color_mid | |
else: | |
get(\"theme_override_styles/fill\").bg_color = value_color_low | |
" | |
[sub_resource type="Gradient" id="Gradient_qfd2w"] | |
[sub_resource type="GradientTexture2D" id="GradientTexture2D_8das8"] | |
gradient = SubResource("Gradient_qfd2w") | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_pjn43"] | |
texture = SubResource("GradientTexture2D_8das8") | |
modulate_color = Color(0, 0, 1, 1) | |
[sub_resource type="GDScript" id="GDScript_ll802"] | |
script/source = "extends ProgressBar | |
@export_range(0.0,2.0) var value_rate = 0.5 | |
@export var value_style_high : StyleBoxTexture | |
@export var value_style_mid : StyleBoxTexture | |
@export var value_style_low := StyleBoxTexture | |
var _value_flip : bool | |
func _process(delta: float) -> void: | |
_anim_value() | |
_color_progress() | |
func _anim_value(): | |
value += -value_rate + 2.0 * value_rate * (_value_flip as int) | |
if value <= min_value or value >= max_value: | |
_value_flip = !_value_flip | |
func _color_progress(): | |
if value >= max_value * 0.7: | |
set(\"theme_override_styles/fill\" , value_style_high) | |
elif value >= max_value * 0.4: | |
set(\"theme_override_styles/fill\" , value_style_mid) | |
else: | |
set(\"theme_override_styles/fill\" , value_style_low) | |
" | |
[sub_resource type="Gradient" id="Gradient_5xrgf"] | |
interpolation_mode = 1 | |
offsets = PackedFloat32Array(0, 0.25, 0.5, 0.75, 1) | |
colors = PackedColorArray(0.498039, 0.498039, 0.498039, 1, 1, 1, 1, 1, 0.498039, 0.498039, 0.498039, 1, 1, 1, 1, 1, 0, 0, 0, 1) | |
[sub_resource type="GradientTexture2D" id="GradientTexture2D_swyer"] | |
gradient = SubResource("Gradient_5xrgf") | |
fill_to = Vector2(0, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_15f7y"] | |
texture = SubResource("GradientTexture2D_swyer") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(0, 1, 0, 1) | |
[sub_resource type="GradientTexture2D" id="GradientTexture2D_li3sq"] | |
gradient = SubResource("Gradient_5xrgf") | |
fill_from = Vector2(1, 0) | |
fill_to = Vector2(0, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_nxui4"] | |
texture = SubResource("GradientTexture2D_li3sq") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(1, 0.843, 0, 1) | |
[sub_resource type="GradientTexture2D" id="GradientTexture2D_se0s1"] | |
gradient = SubResource("Gradient_5xrgf") | |
fill_from = Vector2(1, 1) | |
fill_to = Vector2(0, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_cmukx"] | |
texture = SubResource("GradientTexture2D_se0s1") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(0.863, 0.078, 0.235, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_ga80m"] | |
texture = SubResource("GradientTexture2D_swyer") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(0.301961, 0.313726, 1, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_r4l1h"] | |
texture = SubResource("GradientTexture2D_li3sq") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(0.301961, 0.313726, 1, 1) | |
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_k14cq"] | |
texture = SubResource("GradientTexture2D_se0s1") | |
axis_stretch_horizontal = 1 | |
modulate_color = Color(0.301961, 0.313726, 1, 1) | |
[node name="Control" type="Control"] | |
layout_mode = 3 | |
anchors_preset = 15 | |
anchor_right = 1.0 | |
anchor_bottom = 1.0 | |
grow_horizontal = 2 | |
grow_vertical = 2 | |
metadata/_edit_lock_ = true | |
[node name="VBoxContainer" type="VBoxContainer" parent="."] | |
layout_mode = 1 | |
offset_right = 200.0 | |
[node name="ProgressBarColor" type="ProgressBar" parent="VBoxContainer"] | |
custom_minimum_size = Vector2(0, 40) | |
layout_mode = 2 | |
theme_override_styles/fill = SubResource("StyleBoxFlat_vq0ld") | |
value = 60.0 | |
show_percentage = false | |
script = SubResource("GDScript_f68c0") | |
[node name="ProgressBarPatten" type="ProgressBar" parent="VBoxContainer"] | |
custom_minimum_size = Vector2(0, 40) | |
layout_mode = 2 | |
theme_override_styles/fill = SubResource("StyleBoxTexture_pjn43") | |
value = 90.0 | |
show_percentage = false | |
script = SubResource("GDScript_ll802") | |
value_style_high = SubResource("StyleBoxTexture_15f7y") | |
value_style_mid = SubResource("StyleBoxTexture_nxui4") | |
value_style_low = SubResource("StyleBoxTexture_cmukx") | |
[node name="ProgressBarPatten2" type="ProgressBar" parent="VBoxContainer"] | |
custom_minimum_size = Vector2(0, 40) | |
layout_mode = 2 | |
theme_override_styles/fill = SubResource("StyleBoxTexture_pjn43") | |
value = 30.0 | |
show_percentage = false | |
script = SubResource("GDScript_ll802") | |
value_style_high = SubResource("StyleBoxTexture_ga80m") | |
value_style_mid = SubResource("StyleBoxTexture_r4l1h") | |
value_style_low = SubResource("StyleBoxTexture_k14cq") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment