-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcoloraug.tex
89 lines (74 loc) · 2.39 KB
/
coloraug.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
% Last modified 2018-06-28
% Dorai Sitaram
\let\maybeendinput\relax
\ifx\shipout\UnDeFiNeD
\let\maybeendinput\endinput
\else\edef\fmtnameQplain{plain}%
\ifx\fmtname\fmtnameQplain\else
\let\maybeendinput\endinput
\fi
\fi\maybeendinput
% Load color.sty, which defines rgb, cmyk, gray.
% It also defines hsb, but not for LuaTeX.
\ifx\definecolor\UnDeFiNeD
\ifx\miniltx\UnDeFiNeD
\input miniltx
\fi
\input color.sty
\fi
\let\colorQorig\color
\let\definecolorQorig\definecolor
\def\color{\futurelet\colorQi\colorQii}
\def\colorQii{\ifx\colorQi[\let\colorQiii\colorQwithmodel
\else\let\colorQiii\colorQorig\fi\colorQiii}
\let\maybeendinput\relax
\ifx\directlua\UnDeFiNeD
\input colorxe
\let\maybeendinput\endinput
\fi\maybeendinput
\directlua{require(kpse.find_file('colormodels.lua'))}
\def\colorQwithmodel[#1]{\directlua{
local model = '#1'
if model == 'HTML' then
tex.print("\noexpand\\colorQwithmodelnondecimal[" .. model .. "]")
else
tex.print("\noexpand\\colorQwithmodeldecimal[" .. model .. "]")
end
}}
\def\colorQwithmodeldecimal[#1]#2{\directlua{
local model = "#1"
local values = { #2 }
local newmodel, newvalues = convert_to_known_color_model(model, values)
tex.print("\noexpand\\colorQorig[" .. newmodel .. "]" .. convert_to_csv(newvalues))
}}
\def\colorQwithmodelnondecimal[#1]#2{\directlua{
local model = "#1"
local values = { 0x#2 }
local newmodel, newvalues = convert_to_known_color_model(model, values)
tex.print("\noexpand\\colorQorig[" .. newmodel .. "]" .. convert_to_csv(newvalues))
}}
\def\definecolor#1#2{\directlua{
local name = '#1'
local model = '#2'
if model == 'HTML' then
tex.print("\noexpand\\definecolorQnondecimal{" .. name .. "}{" .. model .. "}")
else
tex.print("\noexpand\\definecolorQdecimal{" .. name .. "}{" .. model .. "}")
end
}}
\def\definecolorQdecimal#1#2#3{\directlua{
local name = '#1'
local model = '#2'
local values = { #3 }
local newmodel, newvalues = convert_to_known_color_model(model, values)
tex.print("\noexpand\\definecolorQorig{" .. name .. "}{" .. newmodel .. "}" ..
convert_to_csv(newvalues))
}}
\def\definecolorQnondecimal#1#2#3{\directlua{
local name = '#1'
local model = '#2'
local values = { 0x#3 }
local newmodel, newvalues = convert_to_known_color_model(model, values)
tex.print("\noexpand\\definecolorQorig{" .. name .. "}{" .. newmodel .. "}" ..
convert_to_csv(newvalues))
}}