Debian Codegraph @

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

raw
1 ### file spec-dvipsnam-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 # CMYK color spec
19 /^\\DefineNamedColor\{named\}\{[a-zA-Z]+\} *\{cmyk\}\{[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+\}/ {
20 i++
21 name[i] = $4
22 c[i] = $8
23 m[i] = $9
24 y[i] = $10
25 k[i] = $11
26 # print name[i] "=(" c[i] "," m[i] "," y[i] "," k[i] ")"
27 }
28 END {
29 print "Found " i " DVIPS colors (" version ")."
30 # Build file mpcolornames-spec-dvipsnam-def.mp.
31 file = "mpcolornames-spec-dvipsnam-def.mp"
32 print "%%% file " file > file
33 print "%%% Copyright 2009, 2011 Stephan Hennig" >> file
34 print "%" >> file
35 print "% This work may be distributed and/or modified under the conditions of" >> file
36 print "% the LaTeX Project Public License, either version 1.3 of this license" >> file
37 print "% or (at your option) any later version. The latest version of this" >> file
38 print "% license is in http://www.latex-project.org/lppl.txt" >> file
39 print "%" >> file
40 print "def _mpcolornames_spec_dvipsnam_def=" >> file
41 print "cmykcolor" >> file
42 for (j = 1; j < i; j++) print name[j] "," >> file
43 print name[i] ";" >> file
44 for (j = 1; j <= i; j++) print name[j] ":=(" c[j] "," m[j] "," y[j] "," k[j] ");" >> file
45 print "enddef;" >> file
46 print "endinput" >> file
47
48 # Build file proof-spec-dvipsnam-def.mp.
49 file = "proof-spec-dvipsnam-def.mp"
50 print "%%% file " file > file
51 print "input proof-mpcolornames" >> file
52 print "dvipsnames;" >> file
53 print "defaultcolormodel := 7;% CMYK" >> file
54 print "specname := \"dvipsnam-def\";" >> file
55 for (j = 1; j <= i; j++) print "proof(" name[j] ");" >> file
56 print "end" >> file
57
58 # Build file tab-spec-dvipsnam-def.tex.
59 file = "tab-spec-dvipsnam-def.tex"
60 print "%%% file " file > file
61 print "\\vspace{\\floatsep}" >> file
62 print "\\begin{multicols}{4}[\\noindent\\parbox{\\textwidth}{%" >> file
63 print " \\captionof{table}{CMYK colors from DVIPS specification.}%" >> file
64 print " \\label{tab:spec-dvipsnam-def}%" >> file
65 print " \\footnotesize Taken from file \\texttt{dvipsnam.def} " version " as distributed by \\LaTeX\\ package \\name{color} (" 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[dvipsnam-def]{" name[j] "}\\par" >> file
71 print "\\end{multicols}" >> file
72 }