Debian Codegraph @

texmf-dist/source/metapost/mpcolornames/spec-svgnam-def.awk

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