random

- collection of un-sorted bollocks
git clone git://git.acid.vegas/random.git
Log | Files | Refs | Archive

fckterm (5291B)

      1 #!/bin/bash
      2 
      3 # Global Variables for Fine-Tuning
      4 min_unicode=32  # Minimum Unicode value for random character generation
      5 max_unicode=65535  # Maximum Unicode value for random character generation
      6 min_color=16  # Minimum ANSI color code for text and background
      7 max_color=255  # Maximum ANSI color code for text and background
      8 line_length=100000  # Maximum line length until it's reset
      9 reset_line_chars=900  # Characters to remove when resetting the line
     10 emoji_frequency_min=1  # Minimum frequency for emoji insertion (characters)
     11 emoji_frequency_max=10  # Maximum frequency for emoji insertion (characters)
     12 sleep_min=100  # Minimum sleep delay between characters (microseconds)
     13 sleep_max=1000  # Maximum sleep delay between characters (microseconds)
     14 text_color_frequency_min=10000  # Minimum frequency for text color change (characters)
     15 text_color_frequency_max=5000000  # Maximum frequency for text color change (characters)
     16 background_color_frequency_min=100  # Minimum frequency for background color change (characters)
     17 background_color_frequency_max=3000  # Maximum frequency for background color change (characters)
     18 reset_color_frequency_min=100  # Minimum frequency for color reset (characters)
     19 reset_color_frequency_max=500  # Maximum frequency for color reset (characters)
     20 reset_line_frequency=500  # Reset line every 100 characters
     21 reset_line_delay=0.05  # Delay after resetting line (seconds)
     22 
     23 # Function to generate a random Unicode character
     24 generate_random_unicode_char() {
     25   random_unicode=$((min_unicode + RANDOM % (max_unicode - min_unicode + 1)))
     26   printf "\\$(printf '%03o' "$random_unicode")"
     27 }
     28 
     29 # Function to generate a random ANSI escape code for color
     30 generate_random_color() {
     31   random_color=$((min_color + RANDOM % (max_color - min_color + 1)))
     32   printf "\\e[38;5;%sm" "$random_color"
     33 }
     34 
     35 # Function to generate a random ANSI escape code for background color
     36 generate_random_background_color() {
     37   random_color=$((min_color + RANDOM % (max_color - min_color + 1)))
     38   printf "\\e[48;5;%sm" "$random_color"
     39 }
     40 
     41 # Function to generate a random emoji
     42 generate_random_emoji() {
     43   random_emoji_code=$((RANDOM % (129511 - 128512 + 1) + 128512))
     44   printf "\\U$(printf '%04x' "$random_emoji_code")"
     45 }
     46 
     47 # Initialize an empty line
     48 line=""
     49 current_line_length=0
     50 
     51 # Counter for tracking character count
     52 char_count=0
     53 
     54 # Initialize variables for tracking various frequencies
     55 emoji_insertion_frequency=0
     56 sleep_delay_random=0
     57 text_color_change_frequency=0
     58 background_color_change_frequency=0
     59 reset_color_frequency=0
     60 color_reset=false
     61 
     62 while true; do
     63   # Generate a random Unicode character
     64   random_char=$(generate_random_unicode_char)
     65 
     66   # Append the new character to the line with random formatting
     67   formatted_char="$(generate_random_color)$(generate_random_background_color)$random_char\\e[0m"
     68   line="$line$formatted_char"
     69 
     70   # Increment character count
     71   char_count=$((char_count + 1))
     72 
     73   # Check if it's time to insert an emoji (random frequency)
     74   if [ "$emoji_insertion_frequency" -gt 0 ] && [ $((char_count % emoji_insertion_frequency)) -eq 0 ]; then
     75     random_emoji=$(generate_random_emoji)
     76     line="$line$random_emoji"
     77   fi
     78 
     79   # Check if it's time to change text color (random frequency)
     80   if [ "$text_color_change_frequency" -gt 0 ] && [ $((char_count % text_color_change_frequency)) -eq 0 ]; then
     81     generate_random_color  # Generate a new random text color
     82   fi
     83 
     84   # Check if it's time to change background color (random frequency)
     85   if [ "$background_color_change_frequency" -gt 0 ] && [ $((char_count % background_color_change_frequency)) -eq 0 ]; then
     86     generate_random_background_color  # Generate a new random background color
     87   fi
     88 
     89   # Check if it's time to reset colors (random frequency)
     90   if [ "$reset_color_frequency" -gt 0 ] && [ $((char_count % reset_color_frequency)) -eq 0 ]; then
     91     color_reset=true
     92   fi
     93 
     94   # Limit the line length and reset when it reaches a certain length
     95   current_line_length=${#line}
     96   if [ "$current_line_length" -gt "$line_length" ]; then
     97     line="${line:$reset_line_chars}"
     98     current_line_length=$line_length
     99   fi
    100 
    101   # Print the line with random formatting
    102   if [ "$color_reset" = true ]; then
    103     echo -n -e "\\e[0m$line"  # Reset colors
    104     color_reset=false
    105   else
    106     echo -n -e "$line"
    107   fi
    108 
    109   # Sleep for a randomized time between specified min and max delays
    110   sleep_delay_random=$((RANDOM % (sleep_max - sleep_min + 1) + sleep_min))
    111   sleep_time=$(bc -l <<< "scale=5; $sleep_delay_random / 1000000")  # Convert to seconds
    112   sleep "$sleep_time"
    113 
    114   # Randomly pick a spot on the terminal to start a new line every reset_line_frequency characters
    115   if [ $((char_count % reset_line_frequency)) -eq 0 ]; then
    116     tput cup $((RANDOM % 30)) $((RANDOM % 100))
    117     current_line_length=0
    118     line=""
    119     color_reset=true  # Apply color reset
    120     reset_chars=$((RANDOM % 91 + 10))  # Append 100 to 1000 spaces
    121     for _ in $(seq 1 "$reset_chars"); do
    122       line="$line "
    123     done
    124     sleep "$reset_line_delay"  # Delay after resetting line
    125   fi
    126 
    127   # Check if it's time to change background color (random frequency)
    128   if [ "$background_color_change_frequency" -gt 0 ] && [ $((char_count % background_color_change_frequency)) -eq 0 ]; then
    129     generate_random_background_color  # Generate a new random background color
    130   fi
    131 done