Debian Codegraph @

texmf-dist/doc/luatex/farbe/farbe-doc.tex

raw
1 \documentclass{ltxdoc}
2
3 \setcounter{tocdepth}{4}
4 \setcounter{secnumdepth}{4}
5
6 \EnableCrossrefs
7 \CodelineIndex
8 \RecordChanges
9
10 \usepackage{mdframed}
11 \usepackage{minted}
12 \usepackage{multicol}
13 \usepackage{luacode}
14 \usepackage{farbe}
15
16 \usemintedstyle{friendly}
17 \BeforeBeginEnvironment{minted}{\begin{mdframed}}
18 \AfterEndEnvironment{minted}{\end{mdframed}}
19 \setminted{
20 breaklines=true,
21 fontsize=\footnotesize,
22 style=manni,
23 }
24 \def\lua#1{\mintinline{lua}|#1|}
25 \def\latex#1{\mintinline{latex}|#1|}
26
27 \NewDocumentCommand { \InputLatex } { O{} m } {
28 \begin{mdframed}
29 \inputminted[linenos=false,#1]{latex}{examples/#2}
30 \end{mdframed}
31 }
32
33 \NewDocumentCommand { \InputLua } { O{} m } {
34 \begin{mdframed}
35 \inputminted[linenos=false,#1]{lua}{examples/#2}
36 \end{mdframed}
37 }
38
39 \begin{document}
40
41 \providecommand*{\url}{\texttt}
42
43 \title{The \textsf{farbe} package}
44 \author{%
45 Josef Friedrich\\%
46 \url{[email protected]}\\%
47 \href{https://github.com/Josef-Friedrich/farbe}
48 {github.com/Josef-Friedrich/farbe}%
49 }
50 \date{0.2.0 from 2025/06/08}
51
52 \maketitle
53
54 \newpage
55
56 \tableofcontents
57
58 \newpage
59
60 % \section{Einführung}
61 \section{Introduction}
62
63 Color management (conversion, names) for Lua\TeX{} implemented in Lua.
64
65 \emph{farbe} is mainly a Lua library for converting and manipulating
66 colors. It is based on Lua module
67 \href{https://luarocks.org/modules/Firanel/lua-color}{lua-color}.
68
69 % CTAN stellt eine Übersichtsseite zum Thema bereit.
70 CTAN provides an overview page on the subject of
71 \href{https://www.ctan.org/topic/colour}
72 {Colour: packages to typesetting in colour}.
73
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
78 \section{Lua interface / API}
79
80 \subsection{Class “Color”}
81
82 \subsubsection{Fields}
83
84 \paragraph{Color.r}
85
86 Red component.
87
88 \paragraph{Color.g}
89
90 Green component.
91
92 \paragraph{Color.b}
93
94 Blue component.
95
96 \paragraph{Color.a}
97
98 Alpha component.
99
100 \subsubsection{Methods}
101
102 \paragraph{Color:clone ()}
103
104 Clone color
105
106 \paragraph{Color:set (value)}
107
108 Set color to value.
109
110 \paragraph{Color:rgb ()}
111
112 Get rgb values.
113
114 \paragraph{Color:rgba ()}
115
116 Get rgba values.
117
118 \paragraph{Color:hsv ()}
119
120 Get hsv values.
121
122 \paragraph{Color:hsva ()}
123
124 Get hsv values.
125
126 \paragraph{Color:hsl ()}
127
128 Get hsl values.
129
130 \paragraph{Color:hsla ()}
131
132 Get hsl values.
133
134 \paragraph{Color:hwb ()}
135
136 Get hwb values.
137
138 \paragraph{Color:hwba ()}
139
140 Get hwb values.
141
142 \paragraph{Color:cmyk ()}
143
144 Get cmyk values.
145
146 \paragraph{Color:rotate (value)}
147
148 Rotate hue of color.
149
150 \paragraph{Color:invert ()}
151
152 Invert the color.
153
154 \paragraph{Color:grey ()}
155
156 Reduce saturation to 0.
157
158 \paragraph{Color:blackOrWhite (lightness)}
159
160 Set to black or white depending on lightness.
161
162 \paragraph{Color:mix (other, strength)}
163
164 Mix two colors together.
165
166 \paragraph{Color:complement ()}
167
168 Generate complementary color.
169
170 \paragraph{Color:analogous ()}
171
172 Generate analogous color scheme.
173
174 \paragraph{Color:triad ()}
175
176 Generate triadic color scheme.
177
178 \paragraph{Color:tetrad ()}
179
180 Generate tetradic color scheme.
181
182 \paragraph{Color:compound ()}
183
184 Generate compound color scheme.
185
186 \paragraph{Color:evenlySpaced (n, r)}
187
188 Generate evenly spaced color scheme.
189
190 \paragraph{Color:tostring (format)}
191
192 Get string representation of color.
193
194 \paragraph{Color:band (a, b)}
195
196 Apply rgb mask to color, providing backwards compatibility for Lua 5.1 and LuaJIT 2.1.0-beta3
197
198 \paragraph{Color:isColor (color)}
199
200 Check whether color is a Color.
201
202 \section{\TeX{} interface}
203
204 \begin{minted}{latex}
205 \documentclass{article}
206 \usepackage{color}
207 \usepackage{farbe}
208 \begin{document}
209 \definecolor{my-test-color}{rgb}{.2,0.85,1}
210
211 % Not a valid color: my-test-color
212 % \FarbeTextColor{my-test-color}{This text is set in my test color.}
213
214 \FarbeImport{my-test-color}
215
216 \FarbeTextColor{my-test-color}{This text is set in my test color.}
217 \end{document}
218 \end{minted}
219
220 \begin{macro}{\FarbePdfLiteral}
221
222 \end{macro}
223
224 \begin{macro}{\FarbeColor}
225 \begin{macro}{\FarbeColorEnd}
226 \begin{minted}{latex}
227 This is not green.
228 \FarbeColor{green} This is green. It's still green.
229 \FarbeColorEnd It's not green.
230 \end{minted}
231 \end{macro}
232 \end{macro}
233
234 \begin{macro}{\FarbeTextColor}
235 \begin{minted}{latex}
236 This is not green. \FarbeTextColor{green}{This is green.} This is not green.
237 \end{minted}
238 \end{macro}
239
240 \begin{macro}{\FarbeBox}
241
242 \end{macro}
243
244 \clearpage
245
246 \section{Color names}
247
248 \subsection{base}
249
250 \begin{multicols}{4}
251 \directlua{farbe.print_color_table('base')}
252 \end{multicols}
253
254 \subsection{svg}
255
256 This svg color names are taken from the
257 \href{https://github.com/latex3/xcolor/blob/c5035d41c6070f4e8936196a994ad04336704872/xcolor.dtx#L7134-L7286}{xcolor}
258 package.
259
260 \def\TmpColor#1{\texttt{#1}}
261
262 % https://github.com/latex3/xcolor/blob/c5035d41c6070f4e8936196a994ad04336704872/xcolor.dtx#L2105-L2127
263 {
264 \footnotesize\raggedright Duplicate colors:
265 \TmpColor{Aqua} = \TmpColor{Cyan},
266 \TmpColor{Fuchsia} = \TmpColor{Magenta};
267 \TmpColor{Navy} = \TmpColor{NavyBlue};
268 \TmpColor{Gray} = \TmpColor{Grey},
269 \TmpColor{DarkGray} = \TmpColor{DarkGrey},
270 \TmpColor{LightGray} = \TmpColor{LightGrey},
271 \TmpColor{SlateGray} = \TmpColor{SlateGrey},
272 \TmpColor{DarkSlateGray} = \TmpColor{DarkSlateGrey},
273 \TmpColor{LightSlateGray} = \TmpColor{LightSlateGrey},
274 \TmpColor{DimGray} = \TmpColor{DimGrey}.
275 \par\smallskip
276 HTML4 color keyword subset:
277 \TmpColor{Aqua}, \TmpColor{Black}, \TmpColor{Blue}, \TmpColor{Fuchsia},
278 \TmpColor{Gray}, \TmpColor{Green}, \TmpColor{Lime}, \TmpColor{Maroon},
279 \TmpColor{Navy}, \TmpColor{Olive}, \TmpColor{Purple}, \TmpColor{Red},
280 \TmpColor{Silver}, \TmpColor{Teal}, \TmpColor{White}, \TmpColor{Yellow}.
281 \par\smallskip
282 Colors taken from Unix/X11:
283 \TmpColor{LightGoldenrod},
284 \TmpColor{LightSlateBlue},
285 \TmpColor{NavyBlue},
286 \TmpColor{VioletRed}.
287 }
288
289 \begin{multicols}{4}
290 \directlua{farbe.print_color_table('svg')}
291 \end{multicols}
292
293 \subsection{x11}
294
295 This x11 color names are taken from the
296 \href{https://github.com/latex3/xcolor/blob/c5035d41c6070f4e8936196a994ad04336704872/xcolor.dtx#L7289-L7607}{xcolor}
297 package.
298
299 % https://github.com/latex3/xcolor/blob/c5035d41c6070f4e8936196a994ad04336704872/xcolor.dtx#L2133-L2135
300 {
301 \footnotesize\raggedright Duplicate colors:
302 \TmpColor{Gray0} = \TmpColor{Grey0,},
303 \TmpColor{Green0} = \TmpColor{Green1.}.
304 }
305
306 \begin{multicols}{4}
307 \directlua{farbe.print_color_table('x11')}
308 \end{multicols}
309
310 \clearpage
311
312 \section{Implementation}
313
314 %%
315 %
316 %%
317
318 \subsection{farbe.lua}
319
320 \inputminted[linenos=true]{lua}{farbe.lua}
321
322 %%
323 %
324 %%
325
326 \clearpage
327
328 \subsection{farbe.tex}
329
330 \inputminted[linenos=true]{latex}{farbe.tex}
331
332 %%
333 %
334 %%
335
336 \clearpage
337
338 \subsection{farbe.sty}
339
340 \inputminted[linenos=true]{latex}{farbe.sty}
341
342 \pagebreak
343 \PrintIndex
344 \end{document}