From efc05d341aa0d97918818e1fddc376eb189b576b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vlas=C3=A1k?= Date: Sun, 11 Jul 2021 23:53:41 +0200 Subject: [PATCH] Attempt to improve color documentation --- optex/base/colors.opm | 44 +++++++++++++++++-------------------- optex/doc/optex-userdoc.tex | 8 +++---- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/optex/base/colors.opm b/optex/base/colors.opm index 96f5964b..6b53ce8c 100644 --- a/optex/base/colors.opm +++ b/optex/base/colors.opm @@ -320,30 +320,26 @@ PDF. \TeX/ itself has no concept of colors. Colors have always been handled by inserting whatsits (either using `\special` for DVI or using -`\pdfliteral`/`\pdfcolorstack` for PDF). It is very efficient way of doing -it, \TeX/ doesn't have to know anything about colors, it just inserts the -relevant literals when doing `\shipout`. However, it is also problematic in -many ways. - -This is reason we decide to change colors handling from `\pdfcolorstack` to -\LuaTeX/ attributes in version 1.04 of \OpTeX. Using attributes, the color -setting looks exacly like font selection from \TeX/ point of view: it -respects \TeX/ groups, colors can span to more pages, independent colors -can be set for in all `\insert`s. Moreover, once a material is typeset -(using `\setbox` for example) then it has its fonts and its colors -definitelly set and you can rely on it when you are using `\unhbox` etc.\ -operations. There are no internal whatsits for colors which can interferre -with other typesetting material. - -The \LuaTeX/ attributes can be set like other register settings and after -such a setting, their values are bound to essentially everything \TeX/ creates -(characters, rules, glues, \dots). -We use one attribute \^`\_colorattr` for information of currently selected -color. Setting a color means only to set appropriate value to this attribute. -The value is propagated to each created typesetting element until the attribute -is unset or set to another value. So, setting the attribute behaves exactly -like selecting the font. You can use `{\bf text}` to have text in bold and -`{\Red text}` to have text in red. +`\pdfliteral`/`\pdfcolorstack` for PDF). It is very efficient and \TeX/ doesn't +even have to know anything about colors, but it is also problematic in many +ways. + +That is the reason why we decided to change color handling from +`\pdfcolorstack` to \LuaTeX/ attributes in version 1.04 of \OpTeX. Using +attributes, the color setting behaves exactly like font selection from \TeX/ +point of view: it respects \TeX/ groups, colors can span more pages, +independent colors can be set for `\insert`s, etc. Moreover, once a material is +created (using `\setbox` for example) then it has its fonts and its colors +frozen and you can rely on it when you are using e.g. `\unhbox`. There are no +internal whatsits for colors which can interfere with other typesetting +material. In the end something like setting text to red (`{\Red text}`) should +have the same nice behavior like setting text to bold (`{\bf text}`). + +\LuaTeX/ attributes can be set like count register -- one attribute holds one +number at a time. But the value of attribute is propagated to each created +typesetting element until the attribute is unset or set to another value. Very +much like the font property. We use one attribute \^`\_colorattr` for storing +the currently selected color (in number form). Macros \^`\setcmykcolor``{ }` or \^`\setrgbcolor``{ }` or\nl \^`\setgreycolor``{}` are used in color selectors. These diff --git a/optex/doc/optex-userdoc.tex b/optex/doc/optex-userdoc.tex index 3a0a31a7..b77bdfe6 100644 --- a/optex/doc/optex-userdoc.tex +++ b/optex/doc/optex-userdoc.tex @@ -1413,18 +1413,18 @@ \setbox0=\hbox{#2#3}\leavevmode \rlap{#1\strut \vrule width\wd0}\box0 } -The following example defines the macro for the -\coloron\Yellow\Brown{colored text on the colored background}. Usage: +The following example defines the macro for +\coloron\Yellow\Brown{colored text on colored background}. Usage: `\coloron{}` -The `\coloron` can be defined as follows: +The `\coloron` macro can be defined as follows: \begtt \def\coloron#1#2#3{% \setbox0=\hbox{#2#3}% \leavevmode \rlap{#1\strut \vrule width\wd0}\box0 } -\coloron\Yellow\Brown{The brown text on the yellow background} +\coloron\Yellow\Brown{Brown text on yellow background} \endtt \secc Images