From 93d17caefe21c2fdd87e7e07f7700ee00efa6e65 Mon Sep 17 00:00:00 2001
From: /dev/urandom <johnfkennedy@mail.i2p>
Date: Sat, 15 Feb 2025 02:45:14 +0100
Subject: feat: greetings

---
 greetings.txt |  14 ------
 src/render.rs | 145 ++++++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 116 insertions(+), 43 deletions(-)
 delete mode 100644 greetings.txt

diff --git a/greetings.txt b/greetings.txt
deleted file mode 100644
index fbd8e30..0000000
--- a/greetings.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-greetings to use, as discussed with uwuspace creatures & /dev/urandom @ mountainbytes directly:
-- Venty
-- Erdit
-- Kaede
-- Deja
-- dui
-- vimja
-- cy
-- alu
-- sashu
-- expired bread
-- gaben
-
-DELETE THIS FILE BEFORE RELEASING THE SOURCE CODE!
diff --git a/src/render.rs b/src/render.rs
index bd17e2b..9f86681 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -26,23 +26,28 @@ fn dvd_logo_offset(t: f64, screen_size_x: f64, screen_size_y: f64) -> (f64, f64)
   (offset_x, offset_y)
 }
 
-const START_UWUSPACE: f64 = 0.0;
-const START_BOUNCE: f64 = 0.5;
-const START_SIN: f64 = 1.5;
-const START_COMETOCOSIN: f64 = 2.5;
-const SCENE_GREETINGS: f64 = 20.0;
-const JUST_DVD: f64 = 70.0;
+pub const START_UWUSPACE: f64 = 0.0;
+pub const START_BOUNCE: f64 = 0.5;
+pub const START_SIN: f64 = 1.5;
+pub const START_COMETOCOSIN: f64 = 2.5;
+pub const SCENE_GREETINGS: f64 = 32.0;
+pub const JUST_DVD: f64 = SCENE_GREETINGS + 28.0;
+
+pub const PRINT_TIME: bool = true;
 
 pub fn render(
   canvas: &mut Canvas<Window>,
   texture_creator: &TextureCreator<WindowContext>,
   time_seconds: f64,
 ) {
-  let i = ((time_seconds * 60.0) % 510.0).round();
-  let i = if i > 255.0 {
-    (255.0 - (i - 255.0)) as u8
+  if PRINT_TIME {
+    println!("Time: {time_seconds}\x1b[F");
+  }
+  let colourthing = ((time_seconds * 60.0) % 510.0).round();
+  let colourthing = if colourthing > 255.0 {
+    (255.0 - (colourthing - 255.0)) as u8
   } else {
-    i as u8
+    colourthing as u8
   };
 
   let win_size = canvas.window().drawable_size();
@@ -92,7 +97,10 @@ pub fn render(
         canvas
           .copy(
             &char
-              .to_texture(texture_creator, Color::RGB(i, 64, 255 - i))
+              .to_texture(
+                texture_creator,
+                Color::RGB(colourthing, 64, 255 - colourthing),
+              )
               .unwrap(),
             None,
             char.to_rect(offset as i32 + offset_x, offset_y),
@@ -106,24 +114,100 @@ pub fn render(
   if time_seconds >= JUST_DVD {
     //
   } else if time_seconds >= SCENE_GREETINGS {
-    let mut offset = 0.0;
-    let mut rng = rand::thread_rng();
+    let time_seconds = time_seconds - SCENE_GREETINGS;
+    // Greetings
+    let greeting_header_duration = 4.0;
+    {
+      let mut rng = rand::thread_rng();
 
-    for c in "sorry for shit invite we have adhd".chars() {
-      let char = FONT_GALMURI.get_char(c);
-      canvas
-        .copy(
-          &char
-            .to_texture(texture_creator, Color::RGB(i, 64, 255 - i))
-            .unwrap(),
-          None,
-          char.to_rect(
-            offset as i32 + 18 + rng.gen_range(-2..2),
-            win_size.1 as i32 - 24 + rng.gen_range(-2..2),
-          ),
-        )
-        .unwrap();
-      offset += char.advance_width;
+      let mut i = 0.0;
+      let strlen = 26;
+      let mut uwuoffset_x = 0.0;
+      for c in "Greetings by UwU-Space to:".chars() {
+        let is_not_uwu = i <= 12.0 || i >= 22.0;
+        let char = if is_not_uwu {
+          FONT_GALMURI.get_char(c)
+        } else {
+          FONT_CHERRY_BOMB_ONE.get_char(c)
+        };
+        canvas
+          .copy(
+            &char
+              .to_texture(
+                texture_creator,
+                Color::RGB(colourthing, 64, 255 - colourthing),
+              )
+              .unwrap(),
+            None,
+            char.to_rect(
+              uwuoffset_x as i32 + 18 + rng.gen_range(-2..2),
+              (if is_not_uwu { 24 } else { 16 }) + rng.gen_range(-3..3),
+            ),
+          )
+          .unwrap();
+        uwuoffset_x += char.advance_width;
+        i += 1.0;
+        if i > (time_seconds * (f64::from(strlen) / greeting_header_duration)).floor() {
+          break;
+        }
+      }
+      let mut offset_y = 36;
+      let mut line_index = 0;
+      for line in [
+        vec!["Venty", "Erdit", "Kaede", "dui"],
+        vec!["Deja", "vimja", "cy", "alu"],
+        vec!["sashu", "expired bread", "gaben"],
+      ] {
+        offset_y += 24;
+        let mut offset_x = (f64::from(line_index) * 90.0) + f64::from(win_size.0)
+          - ((time_seconds - greeting_header_duration) * (f64::from(win_size.0) * 0.078125));
+        line_index += 1;
+
+        for c in line.join("   ").chars() {
+          let char = FONT_GALMURI.get_char(c);
+          canvas
+            .copy(
+              &char
+                .to_texture(
+                  texture_creator,
+                  Color::RGB(colourthing, 64, 255 - colourthing),
+                )
+                .unwrap(),
+              None,
+              char.to_rect(
+                offset_x as i32 + 18 + rng.gen_range(-2..2),
+                offset_y + rng.gen_range(-2..2),
+              ),
+            )
+            .unwrap();
+          offset_x += char.advance_width;
+        }
+      }
+    }
+    // Sorry for shit invite
+    {
+      let mut offset = 0.0;
+      let mut rng = rand::thread_rng();
+
+      for c in "sorry for shit invite we have adhd".chars() {
+        let char = FONT_GALMURI.get_char(c);
+        canvas
+          .copy(
+            &char
+              .to_texture(
+                texture_creator,
+                Color::RGB(colourthing, 64, 255 - colourthing),
+              )
+              .unwrap(),
+            None,
+            char.to_rect(
+              offset as i32 + 18 + rng.gen_range(-2..2),
+              win_size.1 as i32 - 24 + rng.gen_range(-2..2),
+            ),
+          )
+          .unwrap();
+        offset += char.advance_width;
+      }
     }
   } else {
     if time_seconds >= START_SIN {
@@ -196,7 +280,10 @@ pub fn render(
         canvas
           .copy(
             &char
-              .to_texture(texture_creator, Color::RGB(i, 64, 255 - i))
+              .to_texture(
+                texture_creator,
+                Color::RGB(colourthing, 64, 255 - colourthing),
+              )
               .unwrap(),
             None,
             char.to_rect(offset as i32, win_size.1 as i32 - 32),
-- 
cgit v1.2.3