Debian Codegraph @

texmf-dist/source/metapost/mpcolornames/spec-plain-mp.awk

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