aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Theme/PieChart/PieChart.tscn
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-08-10 13:00:54 +0200
committer Hop311 <hop3114@gmail.com>2023-08-10 13:00:54 +0200
commit4c43951e70aaa2e7265d3b3f3c4964c048b9328d (patch)
treec6d46df1686710ccacd63ceb16d687cb55877457 /game/src/Game/Theme/PieChart/PieChart.tscn
parent505176d9cabe76cff7cdac6b4d4ef1c77ccb00d9 (diff)
PieChart data and image now come from c++ layer
Diffstat (limited to 'game/src/Game/Theme/PieChart/PieChart.tscn')
-rw-r--r--game/src/Game/Theme/PieChart/PieChart.tscn117
1 files changed, 3 insertions, 114 deletions
diff --git a/game/src/Game/Theme/PieChart/PieChart.tscn b/game/src/Game/Theme/PieChart/PieChart.tscn
index a0d136e..18fb1f1 100644
--- a/game/src/Game/Theme/PieChart/PieChart.tscn
+++ b/game/src/Game/Theme/PieChart/PieChart.tscn
@@ -1,118 +1,8 @@
-[gd_scene load_steps=5 format=3 uid="uid://cr7p1k2xm7mum"]
+[gd_scene load_steps=2 format=3 uid="uid://cr7p1k2xm7mum"]
[ext_resource type="Script" path="res://src/Game/Theme/PieChart/PieChart.gd" id="2_ub6u3"]
-[sub_resource type="Shader" id="Shader_0kffx"]
-code = "shader_type canvas_item;
-
-// The center in UV coordinates, which will always
-//be 0.5, the actual radius will be controlled by the control node
-//const vec2 center = vec2(0.5,0.5);
-uniform float radius = 0.4;
-
-//shadow
-uniform vec2 shadow_displacement = vec2(0.75,0.75);
-uniform float shadow_tightness = 10;
-uniform float shadow_radius = 0.7;
-uniform float shadow_thickness = 1.0;
-
-// Control of the slices
-uniform float stopAngles[5];
-uniform vec3 colours[5];
-
-// Trim
-uniform vec3 trim_colour;
-uniform float trim_size = 0.05;
-
-// The center is spotlighted by the gradient,
-//control its size and falloff with these
-uniform float gradient_falloff = 3.6;
-uniform float gradient_base = 3.1;
-
-// control whether this is a donut instead of a pie chart
-uniform bool donut = false;
-uniform bool donut_inner_trim = false;
-uniform float donut_inner_radius = 0.15;
-
-// get the polar coordinates of a pixel relative to the center
-vec2 getPolar(vec2 UVin, vec2 center){
- vec2 relcoord = (UVin-center);
- float dist = length(relcoord);
- float theta = PI/2.0 + atan((relcoord.y)/(relcoord.x));
- if(UVin.x < 0.5){
- theta += PI;
- }
- return vec2(dist,theta);
-}
-
-// from thebookofshaders, returns a gradient falloff
-float parabola( float base, float x, float k ){
- return pow( base*x*(1.0-x), k );
-}
-
-float parabola_shadow(float base, float x){
- return base*x*x;
-}
-
-void fragment() {
- vec2 coords = getPolar(UV,vec2(0.5,0.5));
- float dist = coords.x;
- float theta = coords.y;
-
- vec2 shadow_polar = getPolar(UV,vec2(0.0+shadow_displacement.x,0.0+shadow_displacement.y));
- float shadow_peak = radius+(radius-donut_inner_radius)/2.0;
- float shadow_gradient = shadow_thickness+parabola_shadow(shadow_tightness*-10.0,shadow_polar.x+shadow_peak-shadow_radius);
-
- // inner hole of the donut => make it transparent
- if(donut && dist <= donut_inner_radius){
- COLOR = vec4(0.1,0.1,0.1,shadow_gradient);
- }
- // inner trim
- else if(donut && donut_inner_trim && dist <= donut_inner_radius + trim_size){
- COLOR = vec4(trim_colour,1.0);
- }
- // interior
- else if(dist <= radius-trim_size){
- for(int i=0;i<stopAngles.length();i++){
- if(theta <= stopAngles[i]){
- float gradient = parabola(gradient_base,dist,gradient_falloff);
- COLOR = vec4(colours[i]*(1.0-gradient),1.0);
- break;
- }
- }
- }
- // outer trim
- else if(dist <= radius){
- COLOR = vec4(trim_colour,1.0);
- }
- //outside the circle
- else{
- COLOR = vec4(0.1,0.1,0.1,shadow_gradient);
- }
-}"
-
-[sub_resource type="ShaderMaterial" id="ShaderMaterial_aadl6"]
-resource_name = "Piechart_shader"
-shader = SubResource("Shader_0kffx")
-shader_parameter/radius = 0.4
-shader_parameter/shadow_displacement = Vector2(0.6, 0.6)
-shader_parameter/shadow_tightness = 1.0
-shader_parameter/shadow_radius = 0.6
-shader_parameter/shadow_thickness = 1.0
-shader_parameter/stopAngles = [3.14159, 5.02655, 6.28319]
-shader_parameter/colours = [Vector3(0, 0, 1), Vector3(1, 1, 0), Vector3(0.4, 0, 0.6)]
-shader_parameter/trim_colour = Vector3(0, 0, 0)
-shader_parameter/trim_size = 0.02
-shader_parameter/gradient_falloff = 3.6
-shader_parameter/gradient_base = 3.1
-shader_parameter/donut = false
-shader_parameter/donut_inner_trim = true
-shader_parameter/donut_inner_radius = 0.25
-
-[sub_resource type="CanvasTexture" id="CanvasTexture_xntmh"]
-
-[node name="PieChart" type="TextureRect" node_paths=PackedStringArray("RichTooltip")]
-material = SubResource("ShaderMaterial_aadl6")
+[node name="PieChart" type="TextureRect" node_paths=PackedStringArray("_rich_tooltip")]
custom_minimum_size = Vector2(50, 50)
anchors_preset = -1
anchor_right = 0.039
@@ -121,10 +11,9 @@ offset_right = -32.92
offset_bottom = -34.68
size_flags_horizontal = 4
size_flags_vertical = 4
-texture = SubResource("CanvasTexture_xntmh")
expand_mode = 3
script = ExtResource("2_ub6u3")
-RichTooltip = NodePath("RichToolTip")
+_rich_tooltip = NodePath("RichToolTip")
[node name="RichToolTip" type="RichTextLabel" parent="."]
visible = false