Commit 6c05124f1bb267dabaf799bd8ee42b6c3dcb520b

Authored by Ian Foster
1 parent e7e369c08e
Exists in master

added new scripts for testing colors

Showing 2 changed files with 172 additions and 0 deletions Inline Diff

scripts/256color.pl View file @ 6c05124
File was created 1 #!/usr/bin/perl
2 # Author: Todd Larason <jtl@molehill.org>
3 # $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
4
5 # use the resources for colors 0-15 - usually more-or-less a
6 # reproduction of the standard ANSI colors, but possibly more
7 # pleasing shades
8
9 # colors 16-231 are a 6x6x6 color cube
10 for ($red = 0; $red < 6; $red++) {
11 for ($green = 0; $green < 6; $green++) {
12 for ($blue = 0; $blue < 6; $blue++) {
13 printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
14 16 + ($red * 36) + ($green * 6) + $blue,
15 ($red ? ($red * 40 + 55) : 0),
16 ($green ? ($green * 40 + 55) : 0),
17 ($blue ? ($blue * 40 + 55) : 0));
18 }
19 }
20 }
21
22 # colors 232-255 are a grayscale ramp, intentionally leaving out
23 # black and white
24 for ($gray = 0; $gray < 24; $gray++) {
25 $level = ($gray * 10) + 8;
26 printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
27 232 + $gray, $level, $level, $level);
28 }
29
30
31 # display the colors
32
33 # first the system ones:
34 print "System colors:\n";
35 for ($color = 0; $color < 8; $color++) {
36 print "\x1b[48;5;${color}m ";
37 }
38 print "\x1b[0m\n";
39 for ($color = 8; $color < 16; $color++) {
40 print "\x1b[48;5;${color}m ";
41 }
42 print "\x1b[0m\n\n";
43
44 # now the color cube
45 print "Color cube, 6x6x6:\n";
46 for ($green = 0; $green < 6; $green++) {
47 for ($red = 0; $red < 6; $red++) {
48 for ($blue = 0; $blue < 6; $blue++) {
49 $color = 16 + ($red * 36) + ($green * 6) + $blue;
50 print "\x1b[48;5;${color}m ";
51 }
52 print "\x1b[0m ";
53 }
54 print "\n";
scripts/pipes.sh View file @ 6c05124
File was created 1 #!/bin/bash
2 # The author of the original script is unknown to me. The first entry I can
3 # find was posted at 2010-03-21 09:50:09 on Arch Linux Forums (doesn't mean the
4 # poster is the author at all):
5 #
6 # https://bbs.archlinux.org/viewtopic.php?pid=728932#p728932
7 #
8 # I, Yu-Jie Lin, made a few changes and additions:
9 #
10 # -p, -t, -R, and -C
11 #
12 # Screenshot: http://flic.kr/p/dRnLVj
13 # Screencast: http://youtu.be/5XnGSFg_gTk
14 #
15 # And push the commits to Gist:
16 #
17 # https://gist.github.com/4689307
18 #
19 # I, Devin Samarin, made a few changes and additions:
20 #
21 # -r can be 0 to mean "no limit".
22 # Reset cursor visibility after done.
23 # Cleanup for those people who want to quit with ^C
24 #
25 # Pushed the changes to https://gist.github.com/4725048
26
27 p=1
28 f=75 s=13 r=2000 t=0
29 w=$(tput cols) h=$(tput lines)
30 # ab -> idx = a*4 + b
31 # 0: up, 1: right, 2: down, 3: left
32 # 00 means going up , then going up -> ┃
33 # 12 means going right, then going down -> ┓
34 sets=(
35 "┃┏ ┓┛━┓ ┗┃┛┗ ┏━"
36 "│╭ ╮╯─╮ ╰│╯╰ ╭─"
37 "│┌ ┐┘─┐ └│┘└ ┌─"
38 "║╔ ╗╝═╗ ╚║╝╚ ╔═"
39 )
40 v="${sets[0]}"
41 RNDSTART=0
42 NOCOLOR=0
43
44 OPTIND=1
45 while getopts "p:t:f:s:r:RCh" arg; do
46 case $arg in
47 p) ((p=(OPTARG>0)?OPTARG:p));;
48 t) ((OPTARG>=0 && OPTARG<${#sets[@]})) && v="${sets[OPTARG]}";;
49 f) ((f=(OPTARG>19 && OPTARG<101)?OPTARG:f));;
50 s) ((s=(OPTARG>4 && OPTARG<16 )?OPTARG:s));;
51 r) ((r=(OPTARG>=0)?OPTARG:r));;
52 R) RNDSTART=1;;
53 C) NOCOLOR=1;;
54 h) echo -e "Usage: $(basename $0) [OPTION]..."
55 echo -e "Animated pipes terminal screensaver.\n"
56 echo -e " -p [1-]\tnumber of pipes (D=1)."
57 echo -e " -t [0-$((${#sets[@]} - 1))]\ttype of pipes (D=0)."
58 echo -e " -f [20-100]\tframerate (D=75)."
59 echo -e " -s [5-15]\tprobability of a straight fitting (D=13)."
60 echo -e " -r LIMIT\treset after x characters, 0 if no limit (D=2000)."
61 echo -e " -R \t\trandom starting point."
62 echo -e " -C \t\tno color."
63 echo -e " -h\t\thelp (this screen).\n"
64 exit 0;;
65 esac
66 done
67
68 cleanup() {
69 tput rmcup
70 tput cnorm
71 exit 0
72 }
73 trap cleanup SIGHUP SIGINT SIGTERM
74
75 for (( i=1; i<=p; i++ )); do
76 c[i]=$((i%8)) n[i]=0 l[i]=0
77 ((x[i]=RNDSTART==1?RANDOM*w/32768:w/2))
78 ((y[i]=RNDSTART==1?RANDOM*h/32768:h/2))
79 done
80
81 tput smcup
82 tput reset
83 tput civis
84 while ! read -t0.0$((1000/f)) -n1; do
85 for (( i=1; i<=p; i++ )); do
86 # New position:
87 ((${l[i]}%2)) && ((x[i]+=-${l[i]}+2,1)) || ((y[i]+=${l[i]}-1))
88
89 # Loop on edges (change color on loop):
90 ((${x[i]}>w||${x[i]}<0||${y[i]}>h||${y[i]}<0)) && ((c[i]=RANDOM%8))
91 ((x[i]=(x[i]+w)%w))
92 ((y[i]=(y[i]+h)%h))
93
94 # New random direction:
95 ((n[i]=RANDOM%s-1))
96 ((n[i]=(${n[i]}>1||${n[i]}==0)?${l[i]}:${l[i]}+${n[i]}))
97 ((n[i]=(${n[i]}<0)?3:${n[i]}%4))
98
99 # Print: