| 1 |
### file spec-x11nam-def.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 |
j = 0 |
| 13 |
} |
| 14 |
# file version |
| 15 |
/\[[0-9]+\/[0-9]+\/[0-9]+ v[0-9.]+[a-z]* .*\]/ { |
| 16 |
match($0, "v[0-9.]+[a-z]*") |
| 17 |
version = substr($0, RSTART, RLENGTH) |
| 18 |
} |
| 19 |
# RGB color spec |
| 20 |
/^[a-zA-Z]+[0-9],[0-9.]+,[0-9.]+,[0-9.]+[;}]/ { |
| 21 |
i++ |
| 22 |
name[i] = $1 |
| 23 |
r[i] = $2 |
| 24 |
g[i] = $3 |
| 25 |
b[i] = $4 |
| 26 |
basename = name[i] |
| 27 |
sub(/[0-9]+$/, "", basename) |
| 28 |
flag = 0 |
| 29 |
for (n = 1; n <= j; n++) |
| 30 |
if (bname[n] == basename) flag = 1 |
| 31 |
if (flag == 0) { |
| 32 |
j++ |
| 33 |
bname[j] = basename |
| 34 |
} |
| 35 |
# print basename ":" name[i] "=(" r[i] "," g[i] "," b[i] ")" |
| 36 |
} |
| 37 |
END { |
| 38 |
print "Found " i " X11 colors (" version ")." |
| 39 |
print "Found " j " X11 color base names." |
| 40 |
# Build file mpcolornames-spec-x11nam-def.mp. |
| 41 |
file = "mpcolornames-spec-x11nam-def.mp" |
| 42 |
print "%%% file " file > file |
| 43 |
print "%%% Copyright 2009, 2011 Stephan Hennig" >> file |
| 44 |
print "%" >> file |
| 45 |
print "% This work may be distributed and/or modified under the conditions of" >> file |
| 46 |
print "% the LaTeX Project Public License, either version 1.3 of this license" >> file |
| 47 |
print "% or (at your option) any later version. The latest version of this" >> file |
| 48 |
print "% license is in http://www.latex-project.org/lppl.txt" >> file |
| 49 |
print "%" >> file |
| 50 |
print "def _mpcolornames_spec_xelevennam_def=" >> file |
| 51 |
print "rgbcolor" >> file |
| 52 |
for (n = 1; n < j; n++) print bname[n] "[]," >> file |
| 53 |
print bname[j] "[];" >> file |
| 54 |
for (n = 1; n <= i; n++) print name[n] ":=(" r[n] "," g[n] "," b[n] ");" >> file |
| 55 |
print "enddef;" >> file |
| 56 |
print "endinput" >> file |
| 57 |
|
| 58 |
# Build file proof-spec-x11nam-def.mp. |
| 59 |
file = "proof-spec-x11nam-def.mp" |
| 60 |
print "%%% file " file > file |
| 61 |
print "input proof-mpcolornames" >> file |
| 62 |
print "defaultcolormodel := 5;% RGB" >> file |
| 63 |
print "specname := \"x11nam-def\";" >> file |
| 64 |
for (n = 1; n <= i; n++) print "proof(" name[n] ");" >> file |
| 65 |
print "end" >> file |
| 66 |
|
| 67 |
# Build file tab-spec-x11nam-def.tex. |
| 68 |
file = "tab-spec-x11nam-def.tex" |
| 69 |
print "%%% file " file > file |
| 70 |
print "\\vspace{\\floatsep}" >> file |
| 71 |
print "\\begin{multicols}{4}[\\noindent\\parbox{\\textwidth}{%" >> file |
| 72 |
print " \\captionof{table}{RGB colors from X11 specification.}%" >> file |
| 73 |
print " \\label{tab:spec-x11nam-def}%" >> file |
| 74 |
print " \\footnotesize Taken from file \\texttt{x11nam.def} " version " as distributed by \\LaTeX\\ package \\name{xcolor} (" i " colors)." >> file |
| 75 |
print " }]" >> file |
| 76 |
print " \\raggedcolumns" >> file |
| 77 |
print " \\setlength{\\parindent}{0pt}" >> file |
| 78 |
print " \\ttfamily\\small\\color{mpcolor}" >> file |
| 79 |
for (n = 1; n <= i; n++) print "\\colorproof[x11nam-def]{" name[n] "}\\par" >> file |
| 80 |
print "\\end{multicols}" >> file |
| 81 |
} |