Debian Codegraph @

texmf-dist/doc/latex/bookshelf/svgnam.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 ###########################################################
4 #
5 # Make a list of the colour selection from the SVG palette
6 # of the xcolor LaTeX package, with calculation of the
7 # brightness/darkness value according to
8 # https://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
9 #
10 # Usage: ./svgnam.sh > svgnam.tex
11 #
12 # Original author: Peter Flynn
13 #
14
15 cat <<EOF
16 %
17 % This is svgnam.tex file generated from svgnam.def by the script
18 % ./svgnam.sh > svgnam.tex
19 %
20 EOF
21
22 PALETTE=`kpsewhich svgnam.def`
23 cat $PALETTE |\
24 grep '^[A-Z][A-Za-z]*,[\.0-9][0-9]*,[\.0-9][0-9]*,[\.0-9][0-9]*' |\
25 awk -F\; '{print $1}' |\
26 awk -F, '{r=$2;g=$3;b=$4} \
27 {brightness=sqrt((0.241*r*r)+(0.691*g*g)+(0.068*b*b))} \
28 {print $1,r,g,b,brightness}' >svgnam.csv
29 cat svgnam.csv |\
30 awk 'BEGIN {print "\\newcommand{\\SIL@svgcolname}[1]{\\ifcase#1 "} \
31 {print $1 "\\or"} END {print "Black\\fi}\n"}'
32 cat svgnam.csv |\
33 awk 'BEGIN {print "\\newcommand{\\SIL@svgcolval}[1]{\\ifcase#1 "} \
34 {print $5 "\\or"} END {print "0\\fi}\n"}'
35 cat svgnam.csv | wc -l |\
36 awk '{print "\\setcounter{SIL@maxcolno}{" $1 "}"}'