{{ message }}

Instantly share code, notes, and snippets.

# GongT/rgb.sh

Last active Sep 16, 2019
color in shell
 #!/bin/bash # rgb R G B # 0 <= RGB <= 5 function rgb() { local R=\$1 G=\$2 B=\$3 echo -n \$(( \$R * 36 + \$G * 6 + \$B + 16 )) }
 #!/bin/bash function test1() { local R G B for R in 0 1 2 3 4 5 ; do for G in 0 1 2 3 4 5 ; do for B in 0 1 2 3 4 5 ; do printf "\e[48;5;\$(rgb \$R \$G \$B)m %3s " \$(rgb \$R \$G \$B) done echo -ne "\e[0m\n" done echo -ne "\e[0m\n" done } function p2() { local CARR=(00 5f 87 af d7 ff) echo -ne "\e[48;5;\$(rgb \$R \$G \$B)m \e[0m" printf " - %3s " \$(rgb \$R \$G \$B) echo -e "(\$R, \$G, \$B) #\${CARR[\$R]}\${CARR[\$G]}\${CARR[\$B]}" } function test2() { local I=16 R=5 G=0 B=0 local GL=\${1-"5"} local GH=\$(( \$GL - 1 )) for G in \$(seq 0 \$GL) ; do p2 done for R in \$(seq \$GH -1 0) ; do p2 done for B in \$(seq 0 \$GL) ; do p2 done for G in \$(seq \$GH -1 0) ; do p2 done for R in \$(seq 0 \$GL) ; do p2 done for B in \$(seq \$GH -1 0) ; do p2 done }

### GongT commented Sep 16, 2019

to join this conversation on GitHub. Already have an account? Sign in to comment