Build a color chart.
This commit is contained in:
@@ -100,6 +100,77 @@ function dump_colors()
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cube_row()
|
||||||
|
{
|
||||||
|
r_base=${1}
|
||||||
|
g=0
|
||||||
|
while (( g < 6 ))
|
||||||
|
do
|
||||||
|
u=0
|
||||||
|
while (( u < 3 ))
|
||||||
|
do
|
||||||
|
r=$(( r_base + u ))
|
||||||
|
|
||||||
|
b=0
|
||||||
|
while (( b < 6 ))
|
||||||
|
do
|
||||||
|
i=$(( 16 + ( r * 36 ) + ( g * 6 ) + ( b ) ))
|
||||||
|
|
||||||
|
txt="" && [ ${g} -lt 3 ] && txt=';37;1'
|
||||||
|
|
||||||
|
printf "[30${txt}m[48;5;${i}m%3i[m " ${i}
|
||||||
|
|
||||||
|
b=$(( b + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
printf ' '
|
||||||
|
|
||||||
|
u=$(( u + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
|
||||||
|
g=$(( g + 1 ))
|
||||||
|
done
|
||||||
|
printf '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
function greyscale_chart()
|
||||||
|
{
|
||||||
|
[ ${i} -ge 244 ] && txt=";30"
|
||||||
|
|
||||||
|
local k=$(( i + 12 ))
|
||||||
|
while (( i < k ))
|
||||||
|
do
|
||||||
|
printf "[48;5;${i};37;1${txt}m%3i[m " ${i}
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
printf '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
function color_chart()
|
||||||
|
{
|
||||||
|
i=0
|
||||||
|
|
||||||
|
# Base 16
|
||||||
|
while (( i < 16 ))
|
||||||
|
do
|
||||||
|
[ ${i} -gt 0 ] && txt=";30"
|
||||||
|
|
||||||
|
printf "[37;1${txt};48;5;${i}m%3i[m " ${i}
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
printf '\n\n'
|
||||||
|
|
||||||
|
r=0;g=0;b=0
|
||||||
|
cube_row 0
|
||||||
|
cube_row 3
|
||||||
|
i=$(( 6 * 6 * 6 + 16 ))
|
||||||
|
|
||||||
|
greyscale_chart
|
||||||
|
greyscale_chart
|
||||||
|
}
|
||||||
|
|
||||||
function setup_color_depth()
|
function setup_color_depth()
|
||||||
{
|
{
|
||||||
use_8_bit=0
|
use_8_bit=0
|
||||||
@@ -383,6 +454,7 @@ function build_sgr_code()
|
|||||||
{
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
dump-colors) dump_colors ;;
|
dump-colors) dump_colors ;;
|
||||||
|
color-chart) color_chart ;;
|
||||||
|
|
||||||
reset) next=0 ;;
|
reset) next=0 ;;
|
||||||
bold) next=1 ;;
|
bold) next=1 ;;
|
||||||
|
|||||||
Reference in New Issue
Block a user