set shaders to move with the scroll of the list
authorEduardo <[email protected]>
Wed, 27 Sep 2023 00:15:58 +0000 (02:15 +0200)
committerEduardo <[email protected]>
Wed, 27 Sep 2023 00:15:58 +0000 (02:15 +0200)
scenes/todo_list/ToDoList.gd
scenes/todo_list/ToDoList.tscn
themes/default/backgrounds/to-do_list_screen_lines.gdshader

index 3af00ddd19e15a242404b335d963c3ed8d436f4b..6518edd8c5728fa2814bc76d8c9f7fa6ed81a369 100644 (file)
@@ -2,6 +2,12 @@ extends Node
 
 signal scene_changed(scene_name)
 
+@onready var background = $Background
+@onready var scroll_container = $ScrollContainer
+
+func _process(_delta):
+       background.material.set_shader_parameter("position", scroll_container.scroll_vertical)
+
 func _notification(what):
        if what == NOTIFICATION_WM_GO_BACK_REQUEST:
                _on_Back_pressed()
@@ -19,3 +25,4 @@ func DEBUG_put_lots_of_tasks(how_many: int):
 
 func _on_ready():
        DEBUG_put_lots_of_tasks(50)
+
index a26a38f3687eae776e99fd5a6e8a30f37213fba1..e0b39481267aeeaea14a1068d4a29c98ed95d0cd 100644 (file)
@@ -13,7 +13,7 @@ shader_parameter/line_width = 6.0
 shader_parameter/interline_space = 100.0
 shader_parameter/right_line_space = 150.0
 shader_parameter/start_lines = 250.0
-shader_parameter/position = 0.07
+shader_parameter/position = 0.0
 
 [node name="ToDoList" type="Node"]
 script = ExtResource("1_733o8")
index 1af3b0a9ecb64f611c624200219c04ba7d4c4be0..74ce5ece63515b6da8548fc79dd48699171155df 100644 (file)
@@ -5,17 +5,21 @@ uniform float line_width = 6.0;
 uniform float interline_space = 100.0;
 uniform float right_line_space = 150.0;
 uniform float start_lines = 250.0;
-uniform float position: hint_range(0.0, 1.0, 0.01) = .07;
+uniform float position: hint_range(0.0, 1000, 1) = 0;
 
 void fragment() {
-       if(FRAGCOORD.y > start_lines) {
-               if(mod(FRAGCOORD.y + start_lines, interline_space) < line_width) {
+       float calc_start =  position - start_lines;
+
+       // dont draw at top
+       if (FRAGCOORD.y > calc_start * -1.) {
+               // draw horizontal lines
+               if (mod(FRAGCOORD.y + calc_start, interline_space) < line_width) {
                        COLOR = line_color;
                }
-               if(FRAGCOORD.x > line_width) {
-                       if(mod(FRAGCOORD.x, 1. / SCREEN_PIXEL_SIZE.x - right_line_space) < line_width) {
-                               COLOR = line_color;
-                       }
+               // draw the right vertical line
+               float c = 1. / SCREEN_PIXEL_SIZE.x - right_line_space;
+               if (c - line_width < FRAGCOORD.x && FRAGCOORD.x < c) {
+                       COLOR = line_color;
                }
        }