From e14b3b44b0ef80fec8a5810cb21a1d3794607c60 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:56:20 +0000 Subject: [PATCH] feat: Make tunnel movement gentle and intermittent This commit modifies the tunnel screensaver to make the movement of the tunnel's center much slower and gentler. It also introduces random pauses (between 5 and 20 seconds) where the center of the tunnel remains stationary. A state machine has been implemented within the main loop to handle the 'moving' and 'paused' states, and the animation speed is now controlled by a new `angle_increment` variable. --- gallery/tunnel/tunnel.sh | 52 ++++++++++++++++++++++++++++++++-------- jury/tunnel.bats | 4 ++-- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/gallery/tunnel/tunnel.sh b/gallery/tunnel/tunnel.sh index a9f4438..87bd7d0 100755 --- a/gallery/tunnel/tunnel.sh +++ b/gallery/tunnel/tunnel.sh @@ -43,6 +43,16 @@ animate() { local frame_counter=0 local frame_buffer="" + # --- New state variables for movement --- + local is_moving=0 # Start in a paused state + local next_state_change_time + next_state_change_time=$(date +%s) + local move_duration=10 # seconds + local min_pause_duration=5 # seconds + local max_pause_duration=20 # seconds + local angle_increment=0.005 # Slow down the movement + + # Plot a point, checking for screen boundaries plot_point() { local x=$1 y=$2 char=$3 color=$4 @@ -60,16 +70,38 @@ animate() { } while true; do - # --- Update center coordinates for a moving tunnel effect (more efficiently) --- - read -r angle center_x center_y < <(awk -v angle="$angle" \ - -v center_x="$original_center_x" -v center_y="$original_center_y" \ - -v offset_x="$center_offset_x" -v offset_y="$center_offset_y" \ - 'BEGIN { - angle += 0.05; - cx = int(center_x + offset_x * cos(angle)); - cy = int(center_y + offset_y * sin(angle)); - print angle, cx, cy; - }') + # --- State management for movement --- + local current_time + current_time=$(date +%s) + if (( current_time >= next_state_change_time )); then + if (( is_moving )); then + # Transition to paused state + is_moving=0 + local pause_duration=$((RANDOM % (max_pause_duration - min_pause_duration + 1) + min_pause_duration)) + next_state_change_time=$((current_time + pause_duration)) + else + # Transition to moving state + is_moving=1 + next_state_change_time=$((current_time + move_duration)) + fi + fi + + # --- Update center coordinates only when moving --- + if (( is_moving )); then + # When moving, the center of the tunnel is continuously recalculated + # to create the illusion of flying through a turning tunnel. + read -r angle center_x center_y < <(awk -v angle="$angle" \ + -v center_x="$original_center_x" -v center_y="$original_center_y" \ + -v offset_x="$center_offset_x" -v offset_y="$center_offset_y" \ + -v angle_increment="$angle_increment" \ + 'BEGIN { + angle += angle_increment; + cx = int(center_x + offset_x * cos(angle)); + cy = int(center_y + offset_y * sin(angle)); + print angle, cx, cy; + }') + fi + frame_buffer="" # Add a new ribbon every few frames diff --git a/jury/tunnel.bats b/jury/tunnel.bats index c9d7ee7..a9ac480 100755 --- a/jury/tunnel.bats +++ b/jury/tunnel.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats -load 'jury/test_libs/bats-support-0.3.0/load.bash' -load 'jury/test_libs/bats-assert-2.2.0/load.bash' +load 'test_libs/bats-support-0.3.0/load.bash' +load 'test_libs/bats-assert-2.2.0/load.bash' SCRIPT="gallery/tunnel/tunnel.sh"