From 504e30e052391d9f7c90c0ea017bd52f6b743840 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:19:54 +0000 Subject: [PATCH] This commit enhances the tunnel screensaver with two new features: 1. The tunnel now draws "off-screen" by increasing the maximum radius of the concentric shapes. This creates a more immersive effect. 2. The center of the tunnel now moves in a smooth, circular path, simulating the effect of going around bends. This is achieved by using `awk` to perform trigonometric calculations for the center coordinates in each frame. The `awk` calls have been optimized to run in a single process per frame for better performance. --- gallery/tunnel/tunnel.sh | 22 +++++++++++++++++++--- jury/tunnel.bats | 0 2 files changed, 19 insertions(+), 3 deletions(-) mode change 100644 => 100755 jury/tunnel.bats diff --git a/gallery/tunnel/tunnel.sh b/gallery/tunnel/tunnel.sh index d50556e..375605d 100755 --- a/gallery/tunnel/tunnel.sh +++ b/gallery/tunnel/tunnel.sh @@ -30,9 +30,14 @@ animate() { width=$(tput cols) local height height=$(tput lines) - local center_x=$((width / 2)) - local center_y=$((height / 2)) - local max_radius=$(( (height > width ? height : width) / 2 + 2 )) + local original_center_x=$((width / 2)) + local original_center_y=$((height / 2)) + local center_x=$original_center_x + local center_y=$original_center_y + local center_offset_x=$((width / 4)) + local center_offset_y=$((height / 4)) + local angle=0 + local max_radius=$((width + height)) local ribbon_spacing=7 local -a radii=() local frame_counter=0 @@ -55,6 +60,17 @@ 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; + }') + frame_buffer="" # Add a new ribbon every few frames if (( frame_counter % ribbon_spacing == 0 )); then diff --git a/jury/tunnel.bats b/jury/tunnel.bats old mode 100644 new mode 100755