checheche/Robo-Bus-A31-HMI/Modules/margin_container_2.tscn
2024-12-13 02:12:00 +08:00

233 lines
7.9 KiB
Plaintext

[gd_scene load_steps=15 format=3 uid="uid://ccp1epic52e7k"]
[ext_resource type="Script" path="res://Modules/SpeedGearAdjustment.gd" id="1_8ml6x"]
[ext_resource type="Texture2D" uid="uid://pomyaut6jtnm" path="res://yuan.png" id="2_5b01c"]
[ext_resource type="Script" path="res://code/speedometer.gd" id="3_xaims"]
[ext_resource type="Texture2D" uid="uid://bgi2o6nm16ycn" path="res://pad_hmi_ui/home/l3_12.png" id="4_d48gs"]
[ext_resource type="Texture2D" uid="uid://0car70lmas3a" path="res://pad_hmi_ui/home/speed_icon.png" id="5_qnams"]
[ext_resource type="Texture2D" uid="uid://bbl68xb2d0ne2" path="res://pad_hmi_ui/home/minus_btn.png" id="6_0j1yn"]
[ext_resource type="Script" path="res://common/base/base_control.gd" id="7_smylr"]
[ext_resource type="Texture2D" uid="uid://py3v278ho7vt" path="res://pad_hmi_ui/home/plus_btn.png" id="8_kef14"]
[ext_resource type="Script" path="res://code/path_follow_2d_por.gd" id="9_34b06"]
[sub_resource type="Shader" id="Shader_f57hx"]
code = "shader_type canvas_item;
uniform float value : hint_range(0.0, 1.0) = 1.0;
uniform int segments = 1;
uniform float radius = 0.475;
uniform float hollow_radius = 0.0;
uniform float margin : hint_range(0.0, 1.0) = 0.0;
uniform float rotation : hint_range(-1.0, 1.0);
uniform float progress_rotation : hint_range(-1.0, 1.0);
uniform sampler2D gradient : source_color;
uniform bool use_value_gradient = false;
uniform sampler2D radius_curve;
vec4 get_gradient_color(sampler2D src, float position) {
position = clamp(position, 0.01, 0.99); // Color at 0.0 and 1.0 get interpolated by both end
return texture(src, vec2(position, 0.5));
}
float map_range(float min1, float max1, float min2, float max2, float v) {
float p = (v - min1) / (max1 - min1);
return p * (max2 - min2) + min2;
}
vec2 rotate_uv(vec2 uv, float p_rotation){
float mid = 0.5;
return vec2(
cos(p_rotation) * (uv.x - mid) + sin(p_rotation) * (uv.y - mid) + mid,
cos(p_rotation) * (uv.y - mid) - sin(p_rotation) * (uv.x - mid) + mid
);
}
float circle_shape(vec2 uv, float p_radius) {
vec2 center = vec2(0.5, 0.5);
return 1.0 - step(p_radius, distance(center, uv));
}
float radial_shape(vec2 uv, int p_segments) {
float radial = 0.0;
uv -= 0.5;
radial = atan(uv.y, uv.x);
radial = map_range(-PI, PI, 0.0, float(p_segments), radial);
radial = mod(radial, 1.0);
return radial;
}
void fragment() {
vec2 uv = UV;
uv = rotate_uv(uv, PI/2.0); // Rotate 90 degrees, so origin pointing at north be default
uv = rotate_uv(uv, rotation * PI);
float t = radial_shape(uv, 1);
if (use_value_gradient) {
t = value;
}
float radius_t = get_gradient_color(radius_curve, radial_shape(uv, 1)).r;
float shape = radial_shape(uv, segments);
float border_size = (1.0-margin)/2.0;
shape *= step(border_size, shape);
shape *= step(shape, 1.0 - border_size);
shape = step(shape, 0.0);
uv = rotate_uv(uv, progress_rotation * PI);
float arc = radial_shape(uv, 1);
arc = step(arc, value/1.*0.82);
float bounds = circle_shape(uv, radius * radius_t);
float hollow = 1.0-circle_shape(uv, hollow_radius * radius_t);
shape = shape * arc * bounds * hollow;
vec4 gradient_color = get_gradient_color(gradient, t);
vec4 color =texture(TEXTURE, UV) ;
//COLOR = vec4(color.r,color.g,color.b,shape);
COLOR = vec4(gradient_color.rgb, shape);
}
"
[sub_resource type="Gradient" id="Gradient_b6vfa"]
offsets = PackedFloat32Array(0, 0.258706, 0.457711, 1)
colors = PackedColorArray(0.968627, 0.686275, 0.945098, 1, 0.498039, 0.314018, 0.990752, 1, 0.443137, 0.270588, 0.996078, 1, 0.968627, 0.686275, 0.945098, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_ghtxh"]
gradient = SubResource("Gradient_b6vfa")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_8xunu"]
shader = SubResource("Shader_f57hx")
shader_parameter/value = 0.0
shader_parameter/segments = 1
shader_parameter/radius = 0.5
shader_parameter/hollow_radius = 0.465
shader_parameter/margin = 0.0
shader_parameter/rotation = 0.167
shader_parameter/progress_rotation = -1.0
shader_parameter/use_value_gradient = false
shader_parameter/gradient = SubResource("GradientTexture1D_ghtxh")
[sub_resource type="Curve2D" id="Curve2D_8vhxy"]
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 101, 370, 0, 0, 0, 0, 74, 352, 0, 0, 0, 0, 46, 323, 0, 0, 0, 0, 20, 279, 0, 0, 0, 0, 12, 260, 0, 0, 0, 0, 10, 249, 0, 0, 0, 0, 7, 229, 0, 0, 0, 0, 9, 179, 0, 0, 0, 0, 12, 156, 0, 0, 0, 0, 19, 132, 0, 0, 0, 0, 34, 102, 0, 0, 0, 0, 54, 75, 0, 0, 0, 0, 79, 52, 0, 0, 0, 0, 106, 33, 0, 0, 0, 0, 131, 22, 0, 0, 0, 0, 156, 12, 0, 0, 0, 0, 188, 6, 0, 0, 0, 0, 222, 5, 0, 0, 0, 0, 272, 18, 0, 0, 0, 0, 327, 48, 0, 0, 0, 0, 356, 79, 0, 0, 0, 0, 378, 114, 0, 0, 0, 0, 393, 154, 0, 0, 0, 0, 401, 192, 0, 0, 0, 0, 399, 223, 0, 0, 0, 0, 390, 268, 0, 0, 0, 0, 377, 299, 0, 0, 0, 0, 360, 325, 0, 0, 0, 0, 336, 352, 0, 0, 0, 0, 314, 365)
}
point_count = 30
[node name="MarginContainer2" type="MarginContainer"]
theme_override_constants/margin_top = 59
script = ExtResource("1_8ml6x")
[node name="Speedometer" type="TextureProgressBar" parent="."]
material = SubResource("ShaderMaterial_8xunu")
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
value = 100.0
fill_mode = 4
radial_initial_angle = 180.0
texture_progress = ExtResource("2_5b01c")
script = ExtResource("3_xaims")
_max_value = 30.0
[node name="TextureRect2" type="TextureRect" parent="Speedometer"]
show_behind_parent = true
layout_mode = 2
offset_right = 406.0
offset_bottom = 378.0
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("4_d48gs")
[node name="GearTextureRect" type="TextureRect" parent="Speedometer"]
layout_mode = 0
offset_left = 84.0
offset_top = 353.0
offset_right = 118.0
offset_bottom = 387.0
pivot_offset = Vector2(17, 17)
texture = ExtResource("5_qnams")
script = ExtResource("7_smylr")
is_Scale = true
[node name="HBoxContainer" type="HBoxContainer" parent="Speedometer"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -91.0
offset_top = -62.0
offset_right = 96.0
offset_bottom = 26.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/separation = 24
[node name="Reduce" type="TextureRect" parent="Speedometer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
texture = ExtResource("6_0j1yn")
script = ExtResource("7_smylr")
is_Scale = true
size_max = 1.1
is_OnClickScaleAwt = null
[node name="Increase" type="TextureRect" parent="Speedometer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
texture = ExtResource("8_kef14")
script = ExtResource("7_smylr")
is_Scale = true
size_max = 1.1
is_OnClickScaleAwt = null
[node name="Path2D" type="Path2D" parent="Speedometer"]
curve = SubResource("Curve2D_8vhxy")
[node name="PathFollow2D" type="PathFollow2D" parent="Speedometer/Path2D" node_paths=PackedStringArray("textureProgressBar", "node")]
position = Vector2(101, 370)
rotation = -2.55359
loop = false
script = ExtResource("9_34b06")
textureProgressBar = NodePath("../..")
node = NodePath("../../GearTextureRect")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = -17
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 18
[node name="ThrottlePositionLabel" type="Label" parent="VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 65
text = "14"
script = ExtResource("7_smylr")
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 34
text = "/"
[node name="Label3" type="Label" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 34
text = "30"
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 34
text = "speed"