Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color slice script #12

Open
nibbula opened this issue May 21, 2018 · 0 comments
Open

color slice script #12

nibbula opened this issue May 21, 2018 · 0 comments

Comments

@nibbula
Copy link

nibbula commented May 21, 2018

Here's something I wrote to test xterm, if you'd like it.

#!/usr/bin/env bash

# Print a slice of color like:
# ________________
# |green      red|
# |              |
# |cyan   magenta|
# ----------------
#
# It should look smooth if your terminal supports enough colors.

#clear
b=0

get_screen_size()
{
  local sizes=$(stty size)
  if [ $? = 0 ] ; then
    set $sizes
    screen_rows="$1"
    screen_cols="$2"
  fi
}

get_screen_size

rows=$((screen_rows - 2))
cols=$((screen_cols - 1))
blue_step=$((255 / rows))
red_green_step=$((255 / cols))

row=0
b=0
while [ $row -lt $rows ] ; do
  col=0
  r=0
  g=255
  while [ $col -lt $cols ] ; do
    #printf "\e[38;2;${r};${g};${b}m#"
    printf "\e[48;2;${r};${g};${b}m "
    r=$((r + red_green_step))
    g=$((g - red_green_step))
    col=$((col + 1))
  done
  printf "\e[0m\n"
  b=$((b + blue_step))
  row=$((row + 1))
done
printf "\e[0m"
exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant