Debian Codegraph @

texmf-dist/source/metapost/mpcolornames/spec-xcolor-sty.awk

raw
1 ### file spec-xcolor-sty.awk
2 ### Copyright 2009, 2011 Stephan Hennig
3 #
4 # This work may be distributed and/or modified under the conditions of
5 # the LaTeX Project Public License, either version 1.3 of this license
6 # or (at your option) any later version. The latest version of this
7 # license is in http://www.latex-project.org/lppl.txt
8 #
9 BEGIN {
10 FS = ",|;|}|{| |/"
11 i = 0
12 }
13 # file version
14 /\[[0-9]+\/[0-9]+\/[0-9]+ v[0-9.]+[a-z]* .*\]/ {
15 match($0, "v[0-9.]+[a-z]*")
16 version = substr($0, RSTART, RLENGTH)
17 }
18 # rgb/hsb/cmyk/gray
19 /[a-z]+,[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+[;}]/ {
20 i++
21 name[i] = $3
22 r[i] = $4
23 g[i] = $5
24 b[i] = $6
25 hu[i] = $7
26 sa[i] = $8
27 br[i] = $9
28 c[i] = $10
29 m[i] = $11
30 y[i] = $12
31 k[i] = $13
32 gry[i] = $14
33 # print name[i] "=(" r[i] "," g[i] "," b[i] ")(" hu[i] "," sa[i] "," br[i] ")(" c[i] "," m[i] "," y[i] "," k[i] ")(" gry[i] ")"
34 }
35 # cmyk/rgb/hsb/gray
36 /[a-z]+,[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+[;}]/ {
37 i++
38 name[i] = $3
39 c[i] = $4
40 m[i] = $5
41 y[i] = $6
42 k[i] = $7
43 r[i] = $8
44 g[i] = $9
45 b[i] = $10
46 hu[i] = $11
47 sa[i] = $12
48 br[i] = $13
49 gry[i] = $14
50 # print name[i] "=(" c[i] "," m[i] "," y[i] "," k[i] ")(" r[i] "," g[i] "," b[i] ")(" hu[i] "," sa[i] "," br[i] ")(" gry[i] ")"
51 }
52 # gray/rgb/hsb/cmyk
53 /[a-z]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+\/[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+[;}]/ {
54 i++
55 name[i] = $3
56 gry[i] = $4
57 r[i] = $5
58 g[i] = $6
59 b[i] = $7
60 hu[i] = $8
61 sa[i] = $9
62 br[i] = $10
63 c[i] = $11
64 m[i] = $12
65 y[i] = $13
66 k[i] = $14
67 # print name[i] "=(" gry[i] ")(" r[i] "," g[i] "," b[i] ")(" hu[i] "," sa[i] "," br[i] ")(" c[i] "," m[i] "," y[i] "," k[i] ")"
68 }
69 END {
70 print "Found " i " base colors (" version ")."
71 # Build file mpcolornames-spec-xcolor-sty.mp.
72 file = "mpcolornames-spec-xcolor-sty.mp"
73 print "%%% file " file > file
74 print "%%% Copyright 2009, 2011 Stephan Hennig" >> file
75 print "%" >> file
76 print "% This work may be distributed and/or modified under the conditions of" >> file
77 print "% the LaTeX Project Public License, either version 1.3 of this license" >> file
78 print "% or (at your option) any later version. The latest version of this" >> file
79 print "% license is in http://www.latex-project.org/lppl.txt" >> file
80 print "%" >> file
81 print "def _mpcolornames_spec_xcolor_sty=" >> file
82 print "rgbcolor" >> file
83 for (j = 1; j < i; j++) print "rgb_" name[j] "," >> file
84 print "rgb_" name[i] ";" >> file
85 print "cmykcolor" >> file
86 for (j = 1; j < i; j++) print "cmyk_" name[j] "," >> file
87 print "cmyk_" name[i] ";" >> file
88 print "numeric" >> file
89 for (j = 1; j < i; j++) print "grey_" name[j] "," >> file
90 print "grey_" name[i] ";" >> file
91 for (j = 1; j <= i; j++) print "rgb_" name[j] ":=(" r[j] "," g[j] "," b[j] ");" >> file
92 for (j = 1; j <= i; j++) print "cmyk_" name[j] ":=(" c[j] "," m[j] "," y[j] "," k[j] ");" >> file
93 for (j = 1; j <= i; j++) print "grey_" name[j] ":=" gry[j] ";" >> file
94 print "enddef;" >> file
95 print "endinput" >> file
96
97
98 # Build file proof-spec-xcolor-sty.mp.
99 file = "proof-spec-xcolor-sty.mp"
100 print "%%% file " file > file
101 print "input proof-mpcolornames" >> file
102 print "specname := \"xcolor-sty\";" >> file
103 print "defaultcolormodel := 5;% RGB" >> file
104 for (j = 1; j <= i; j++) print "proof(rgb_" name[j] ");" >> file
105 print "defaultcolormodel := 7;% CMYK" >> file
106 for (j = 1; j <= i; j++) print "proof(cmyk_" name[j] ");" >> file
107 print "defaultcolormodel := 3;% grey scale" >> file
108 for (j = 1; j <= i; j++) print "proof(grey_" name[j] ");" >> file
109 print "end" >> file
110
111 # Build file tab-spec-xcolor-sty.tex.
112 file = "tab-spec-xcolor-sty.tex"
113 print "%%% file " file > file
114 # print "\\vspace{\\floatsep}" >> file
115 print "\\begingroup" >> file
116 print "\\ttfamily\\small\\color{mpcolor}" >> file
117 print "\\setlength{\\tabcolsep}{.5\\columnsep}" >> file
118 print "\\setlength{\\tabcolwidth}{\\textwidth}" >> file
119 print "\\addtolength{\\tabcolwidth}{-4\\tabcolsep}" >> file
120 print "\\setlength{\\tabcolwidth}{.333\\tabcolwidth}" >> file
121 print "\\begin{longtable}{@{}*{3}{p{\\tabcolwidth}}@{}}" >> file
122 print " \\caption{RGB, CMYK, and grey~scale colors from \\LaTeX\\ package \\name{xcolor}.}%" >> file
123 print " \\label{tab:spec-xcolor-sty}\\\\" >> file
124 print "\\multicolumn{3}{l}{\\normalfont\\footnotesize\\normalcolor Taken from file \\texttt{xcolor.sty} " version " as distributed by \\LaTeX\\ package \\name{xcolor} (" i " colors, with augmented names).}" >> file
125 print "\\endfirsthead" >> file
126 print "" >> file
127 for (j = 1; j <= i; j++) print "\\colorproof[xcolor-sty]{" name[j] "}\\\\" >> file
128 print "\\end{longtable}" >> file
129 print "\\endgroup" >> file
130 }