#!/bin/sh
. ./colors.sh
# $1 is the combined value
# $2 is R, G or B
extract() {
case "$2" in
R) awk "BEGIN{print substr(\"$1\", 1, 2)}" ;;
G) awk "BEGIN{print substr(\"$1\", 3, 2)}" ;;
B) awk "BEGIN{print substr(\"$1\", 5, 2)}" ;;
*) return 1 ;;
esac
}
# hex 2 decimal
# $1 is a number in hex
h2d() {
printf '%d' 0x"$1"
}
# decimal (1-255) 2 real (0-1)
# $1 is an integer from 1 to 255
d2r() {
awk "BEGIN{print $1 / 255}"
}
# $1: color value
# prints full
dict() {
_dict_r=$(d2r $(h2d $(extract $1 R)))
_dict_g=$(d2r $(h2d $(extract $1 G)))
_dict_b=$(d2r $(h2d $(extract $1 B)))
cat <
Color Space
sRGB
Alpha Component
1
Red Component
$_dict_r
Green Component
$_dict_g
Blue Component
$_dict_b
HEREDOC
}
cat <
Theme Name
$theme
Ansi 0 Color
$(dict $black)
Ansi 1 Color
$(dict $red)
Ansi 2 Color
$(dict $green)
Ansi 3 Color
$(dict $yellow)
Ansi 4 Color
$(dict $blue)
Ansi 5 Color
$(dict $magenta)
Ansi 6 Color
$(dict $cyan)
Ansi 7 Color
$(dict $white)
Ansi 8 Color
$(dict $brblack)
Ansi 9 Color
$(dict $brred)
Ansi 10 Color
$(dict $brgreen)
Ansi 11 Color
$(dict $bryellow)
Ansi 12 Color
$(dict $brblue)
Ansi 13 Color
$(dict $brmagenta)
Ansi 14 Color
$(dict $brcyan)
Ansi 15 Color
$(dict $brwhite)
Background Color
$(dict $background)
Foreground Color
$(dict $foreground)
Selected Text Color
$(dict $background)
Selection Color
$(dict $foreground)
Cursor Color
$(dict $foreground)
Cursor Text Color
$(dict $background)
Link Color
$(dict $brblue)
HEREDOC