summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/base/colors.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/optex/base/colors.opm')
-rw-r--r--macros/luatex/optex/base/colors.opm126
1 files changed, 63 insertions, 63 deletions
diff --git a/macros/luatex/optex/base/colors.opm b/macros/luatex/optex/base/colors.opm
index eb57d0d9a8..bbda496761 100644
--- a/macros/luatex/optex/base/colors.opm
+++ b/macros/luatex/optex/base/colors.opm
@@ -1,4 +1,4 @@
-%% This is part of OpTeX project, see http://petr.olsak.net/optex
+%% This is part of the OpTeX project, see http://petr.olsak.net/optex
\_codedecl \colordef {Colors <2020-03-18>} % loaded in format
@@ -7,14 +7,14 @@
\`\localcolor` as default.
\_cod -----------------------------
-\_newifi \_iflocalcolor \_localcolortrue
-\_protected\_def \_localcolor {\_localcolortrue}
+\_newifi \_iflocalcolor \_localcolortrue
+\_protected\_def \_localcolor {\_localcolortrue}
\_protected\_def \_nolocalcolor {\_localcolorfalse}
\_public \localcolor \nolocalcolor ;
\_doc -----------------------------
- The basic colors in CMYK
- \`\Blue` \`\Red` \`\Brown` \`\Green` \`\Yellow` \`\Cyan` \`\Magenta`
+ The basic colors in CMYK
+ \`\Blue` \`\Red` \`\Brown` \`\Green` \`\Yellow` \`\Cyan` \`\Magenta`
\`\Grey` \`\LightGrey` \`\White` and \`\Black`
are declared here.
\_cod -----------------------------
@@ -39,7 +39,7 @@
For example `\setrgbcolor{1 0 0}` expands to `\_setcolor{1 0 0 rg 1 0 0 RG}`.\nl
We set both types of colors (for lines (`K` or `RG` or `G`) and for fills
(`r` or `rg` or `g`) together in the <pdf-primitive> command.
- This is the reason why the \`\_fillstroke` uses both its parameters.
+ This is the reason why the \`\_fillstroke` uses both its parameters.
If only fills are needed you can do `\def\_fillstroke#1#2{#1}`.
If only strokes are needed you can do `\def\_fillstroke#1#2{#2}`.
\_cod -----------------------------
@@ -58,14 +58,14 @@
to its conversion to RGB <pdf-primitive>. This conversion is done by
the \^`\_cmyktorgb` macro. Moreover, `\onlyrgb` re-defines three basic RGB
colors for RGB color space and re-declares \^`\colordef` as \^`\rgbcolordef`.
- The \hbox{\`\onlycmyk`} macro does a similar work, it re-defines \^`\_formatrgb`
+ The \hbox{\`\onlycmyk`} macro does similar work, it re-defines \^`\_formatrgb`
macro. The Grey color space is unchanged and works in both main
settings (RGB or CMYK) without collisions.
\_cod -----------------------------
\_def\_onlyrgb{\_def\Red{\_setrgbcolor{1 0 0}}%
- \_def\Green{\_setrgbcolor{0 1 0}}\_def\Blue{\_setrgbcolor{0 0 1}}%
- \_let\_colordef=\_rgbcolordef
+ \_def\Green{\_setrgbcolor{0 1 0}}\_def\Blue{\_setrgbcolor{0 0 1}}%
+ \_let\_colordef=\_rgbcolordef
\_def\_formatrgb##1{\_fillstroke{##1 rg}{##1 RG}}%
\_def\_formatcmyk##1{\_fillstroke{\_cmyktorgb ##1 ; rg}{\_cmyktorgb ##1 ; RG}}}
\_def\_onlycmyk{\_def\_formatcmyk##1{\_fillstroke{##1 k}{##1 K}}%
@@ -76,18 +76,18 @@
The \`\_setcolor` macro redefines empty `\_ensureblack` macro (used in
output routine for headers and footers) to `\_ensureblackA` which sets
Black at the start of its parameter and returns to the current color at the
- end of its parameter.
-
+ end of its parameter.
+
The current color is saved into `\_currentcolor` macro and colorstack is pushed.
Finally, the `\_colorstackpop` is initialized by `\aftergroup` if
`\localcolor` is declared.
- You can save current color to your macro by `\let\yourmacro=\_currentcolor`
+ You can save the current color to your macro by `\let\yourmacro=\_currentcolor`
and you can return to this color by the command `\_setcolor\yourmacro`.
\_cod -----------------------------
\_protected\_def \_setcolor #1{\_global\_let\_ensureblack=\_ensureblackA
- \_iflocalcolor \_edef\_currentcolor{#1}\_colorstackpush\_currentcolor
+ \_iflocalcolor \_edef\_currentcolor{#1}\_colorstackpush\_currentcolor
\_aftergroup\_colorstackpop
\_else \_xdef\_currentcolor{#1}\_colorstackset\_currentcolor \_fi
}
@@ -97,7 +97,7 @@
\_colorstackpush\_pdfblackcolor #1\_colorstackpop}
\_doc -----------------------------
- The colorstack is initialized here and the basic macros
+ The colorstack is initialized here and the basic macros
\`\_colorstackpush`, \`\_colorstackpop` and \`\_colorstackset`
are defined here.
\_cod -----------------------------
@@ -108,8 +108,8 @@
\_def\_colorstackset#1{\_pdfcolorstack\_colorstackcnt set{#1}}
\_doc -----------------------------
- We need to open a special color stack for footnotes, because footnotes
- can follow on next pages and their colors are independent on colors
+ We need to open a special color stack for footnotes because footnotes
+ can follow on the next pages and their colors are independent of colors
used in the main page-body. The \`\_openfnotestack` is defined as
\`\_openfnotestackA` when the \^`\_setcolor` is used first.
The \`\_fnotestack` is initialized in in `\everyjob` because the
@@ -120,7 +120,7 @@
\_def \_openfnotestackA {\_pdfcolorstack\_fnotestack current}
\_doc -----------------------------
- We use lua codes for RGB to CMYK or CMYK to RGB conversions and for
+ We use Lua codes for RGB to CMYK or CMYK to RGB conversions and for
addition color components in the \^`\colordef` macro.
The \`\_rgbtocmyk` `<R> <G> <B> ;` expands to `<C> <M> <Y> <K>` and
the \`\_cmyktorgb` `<C> <M> <Y> <K> ;` expands to `<R> <G> <B>`.
@@ -170,13 +170,13 @@
\_doc -----------------------------
We have a problem with the `%.3f` directive in Lua code. It prints trailed
zeros: (0.300 instead desired 0.3) but we want to save PDF file space. The macro
- \`\_stripzeros` removes these trailing zeros at expand processor
+ \`\_stripzeros` removes these trailing zeros at the expand processor
level. So `\_stripzeros 0.300 0.400 0.560 ;` expands to `.3 .4 .56`.
\_cod -----------------------------
\_def\_stripzeros #1.#2 #3{\_ifx0#1\_else#1\_fi.\_stripzeroA #2 0 :%
\_ifx;#3\_else \_space \_ea\_stripzeros\_ea#3\_fi}
-\_def\_stripzeroA #10 #2:{\_ifx^#2^\_stripzeroC#1:\_else \_stripzeroB#1 0 :\_fi}
+\_def\_stripzeroA #10 #2:{\_ifx^#2^\_stripzeroC#1:\_else \_stripzeroB#1 0 :\_fi}
\_def\_stripzeroB #10 #2:{\_ifx^#2^\_stripzeroC#1:\_else #1\_fi}
\_def\_stripzeroC #1 #2:{#1}
@@ -184,15 +184,15 @@
The \`\rgbcolordef` and \`\cmykcolordef` use common macro
\`\_commoncolordef` with different first four parameters.
The `\_commoncolordef <selector><K><R><G><what-define>{<data>}` does the
- real work. It initializes the Lua variables for summation.
+ real work. It initializes the Lua variables for summation.
It expands <data> in the group where color selectors have
special meaning, then it adjusts the resulting string by \^`\replstring`
and runs it. Example shows how the <data> are processed:
- \begtt
- input <data>: ".3\Blue + .6^\KhakiC \useK -\Black"
+ \begtt \catcode`\<=13
+ input <data>: ".3\Blue + .6^\KhakiC \useK -\Black"
expanded to: ".3 !=K 1 1 0 0 +.6^!=R .804 .776 .45 \_useK -!=G 0"
adjusted to: "\_addcolor .3!=K 1 1 0 0 \_addcolor .6!^R .804 .776 .45
- \_useK \_addcolor -1!=G 0"
+ \_useK \_addcolor -1!=G 0"
and this is processed.
\endtt
\`\_addcolor` `<coef.>!<mod><type>` expands to `\_addcolor:<mod><type> <coef>`
@@ -203,9 +203,9 @@
processed and lowercase <type> informs that `\rgbcolordef` is processed.
All variants of commands `\_addcolor:<mod><type>` are defined. All of
them expand to `\_addcolorA <v1> <v2> <v3> <v4>` which adds the values of Lua
- variables. The `\rgbcolordef` uses `\_addcolorA <R> <G> <B> 0` and
+ variables. The `\rgbcolordef` uses `\_addcolorA <R> <G> <B> 0` and
`\cmkykcolordef` uses `\_addcolorA <C> <M> <Y> <K>`. So the Lua variable
- names are a little confusing when `\rgbcolordef` is processed.
+ names are a little confusing when `\rgbcolordef` is processed.
Next, `\_commoncolordef` saves resulting values from Lua to `\_tmpb`
using `\_colordefFin`. If `\rgbcolordef` is processed, then we must to
@@ -226,7 +226,7 @@
\_let\_useK=\_relax
\_edef\_tmpb{+#6}%
\_replstring\_tmpb{+ }{+}\_replstring\_tmpb{- }{-}%
- \_replstring\_tmpb{+}{\_addcolor}\_replstring\_tmpb{-}{\_addcolor-}%
+ \_replstring\_tmpb{+}{\_addcolor}\_replstring\_tmpb{-}{\_addcolor-}%
\_replstring\_tmpb{^!=}{!^}\_replstring\_tmpb{-!}{-1!}%
\_ifx K#2\_let\_useK=\_douseK \_fi
\_tmpb
@@ -238,7 +238,7 @@
\_def\_addcolor#1!#2#3{\_cs{addcolor:#2#3}#1}
\_def\_addcolorA #1 #2 #3 #4 #5 {%
\_def\_tmpa{#1}\_ifx\_tmpa\_empty \_else \_edef\_tmpa{\_tmpa*}\_fi
- \_directlua{color_C=math.max(color_C+\_tmpa#2,0)
+ \_directlua{color_C=math.max(color_C+\_tmpa#2,0)
color_M=math.max(color_M+\_tmpa#3,0)
color_Y=math.max(color_Y+\_tmpa#4,0)
color_K=math.max(color_K+\_tmpa#5,0)
@@ -264,7 +264,7 @@
\_let\_colordef=\_cmykcolordef % default \_colordef is \_cmykcolordef
\_doc -----------------------------
- Public versions of \`\colordef` and \`\useK` macros are declared using
+ Public versions of \`\colordef` and \`\useK` macros are declared using
`\_def`, because the internal versions `\_colordef` and `\_useK` are
changed during processing.
\_cod -----------------------------
@@ -281,21 +281,21 @@
\begtt
\def\vr{\vrule height10pt depth2pt width20pt}
\def\_showcolor{\hbox{\tt\_bslash\_tmpb: \csname\_tmpb\endcsname \vr}\space\space}
- \begmulti 4 \typosize[11/14]
+ \begmulti 4 \typosize[11/14]
\morecolors
\endmulti
- \endtt
+ \endtt
\_cod -----------------------------
\_def\_morecolors{%
- \_long\_def\_tmp##1\preparecolorset##2##3##4##5{\_tmpa ##5;,,,;}
- \_def\_tmpa##1,##2,##3,##4;{\_ifx,##1,\_else
- \_def\_tmpb{##1}\_replstring\_tmpb{1}{}\_replstring\_tmpb{2}{B}%
+ \_long\_def\_tmp##1\preparecolorset##2##3##4##5{\_tmpa ##5;,,,;}
+ \_def\_tmpa##1,##2,##3,##4;{\_ifx,##1,\_else
+ \_def\_tmpb{##1}\_replstring\_tmpb{1}{}\_replstring\_tmpb{2}{B}%
\_replstring\_tmpb{3}{C}\_replstring\_tmpb{4}{D}\_replstring\_tmpb{0}{O}%
- \_ifcsname \_tmpb\_endcsname \_else
- \_sdef{\_tmpb}{\_setrgbcolor{##2 ##3 ##4}}\_showcolor\_fi
+ \_ifcsname \_tmpb\_endcsname \_else
+ \_sdef{\_tmpb}{\_setrgbcolor{##2 ##3 ##4}}\_showcolor\_fi
\_ea\_tmpa\_fi
- }
+ }
\_ea\_tmp\_input x11nam.def
}
\_let\_showcolor=\_relax % re-define it if you want to print a color catalog
@@ -303,27 +303,27 @@
\_endcode % -------------------------------------
-The colors have different behavior than fonts. A marks (whatsits) with color
-information are stored into PDF output and \TeX/ doesn't interpret them.
-The PDF viewer (or PDF interpreter in a printer) reads these marks
+The colors have different behavior than fonts. Marks (whatsits) with color
+information are stored into PDF output and \TeX/ doesn't interpret them.
+The PDF viewer (or PDF interpreter in a printer) reads these marks
and switches colors according to them. This
-is totally independent on \TeX/ group mechanism. You can declare
+is independent of \TeX/ group mechanism. You can declare
`\nolocalcolor` at the beginning of the document, if you want this behavior.
-In this case, if you set a color then you must to return back to black color
+In this case, if you set a color then you must return to the black color
using `\Black` manually.
By default, \OpTeX/ sets `\localcolor`. It means that the typesetting
-returns back to a previous color at the end of current group, so you cannot
-write `\Black` explicitly. This is implemented using `\aftergroup` feature.
+returns to a previous color at the end of the current group, so you cannot
+write `\Black` explicitly. This is implemented using the `\aftergroup` feature.
There is a limitation of this feature: when a color selector is used in a
group of a box, which is saved by `\setbox`, then the activity or
-reconstruction of previous color are processed at `\setbox` time, no in the
-box itself. You must correct it by double group:
-\begtt
-\setbox0=\hbox{\Red text} % bad: \Black is done after \setbox
-\setbox0=\hbox{{\Red text}} % good: \Black is done after group inside the box
+reconstruction of the previous color is processed at `\setbox` time, no in the
+box itself. You must correct it by double group:
+\begtt
+\setbox0=\hbox{\Red text} % bad: \Black is done after \setbox
+\setbox0=\hbox{{\Red text}} % good: \Black is done after group inside the box
\endtt
-
+
The implementation of colors is based on colorstack, so the current color
can follow across more pages. It is not so obvious because PDF viewer (or PDF
interpreter) manipulates with colors locally at each PDF page and it
@@ -333,15 +333,15 @@ Macros \^`\setcmykcolor``{<C> <M> <Y> <K>}` or \^`\setrgbcolor``{<R> <G> <B>}`
or\nl \^`\setgreycolor``{<Grey>}` should be used in color selectors or user can
specify these macros explicitly.
-The color mixing processed by the \^`\colordef` is done in the substractive color
+The color mixing processed by the \^`\colordef` is done in the subtractive color
model CMYK. If the result has a component greater than 1 then all
-components are multiplied by a coefficient in order to maximal component is
+components are multiplied by a coefficient in order to the maximal component is
equal to 1.
You can move a shared amount of CMY components (i.e. their minimum) to the
$K$ component. This saves the color tonners and the result is more true.
This should be done by \^`\useK` command at the end of a linear combination
-used in `\colordef`. For example
+used in `\colordef`. For example
\begtt
\colordef \myColor {.3\Green + .4\Blue \useK}
\endtt
@@ -353,26 +353,26 @@ $$
}
$$
-You can use minus instead plus in the linear combination in `\colordef`. The
+You can use minus instead of plus in the linear combination in `\colordef`. The
given color is substracted in such case and the negative components are
rounded to zero immediately. For example
\begtt
-\colordef \Color {\Brown-\Black}
+\colordef \Color {\Brown-\Black}
\endtt
-can be used for removing black component from the color. You can use
-the `-\Black` trick after `\useK` command in order to remove grey components
-occured during color mixing.
+can be used for removing the black component from the color. You can use
+the `-\Black` trick after `\useK` command to remove grey components
+occurred during color mixing.
-Finally, you can use `^` immediately preceeded before macro name of the
+Finally, you can use `^` immediately preceded before the macro name of the
color. Then the complementary color is used here.
\begtt
-\colordef\mycolor{\Grey+.6^\Blue} % the same as \colordef\mycolor{\Grey+.6\Yellow}
+\colordef\mycolor{\Grey+.6^\Blue} % the same as \colordef\mycolor{\Grey+.6\Yellow}
\endtt
The \^`\rgbcolordef` can be used to mix colors in additive color model RGB.
If \^`\onlyrgb` is declared, then \^`\colordef` works as \^`\rgbcolordef`.
-If a CMYK to RGB or RGB to CMYK conversion is needed then
+If a CMYK to RGB or RGB to CMYK conversion is needed then
the following simple formulae are used
(ICC profiles are not supported):
$$
@@ -380,15 +380,15 @@ $$
\hbox{CMYK to RGB:}\cr
R = (1-C)(1-K), \ G = (1-M)(1-K), \ B = (1-Y)(1-K). \cr
\hbox{RGB to CMYK:}\cr
- K'=\max(R,G,B), \ C=(K'-R)/K', \ M=(K'-G)/K', \ Y=(K'-B)/K', \ K=1-K'.
+ K'=\max(R,G,B), \ C=(K'-R)/K', \ M=(K'-G)/K', \ Y=(K'-B)/K', \ K=1-K'.
}
$$
The RGB to CMYK conversion is invoked when a color is declared using `\setrgbcolor`
-and it is used in \^`\colordef` or if it is printed when \^`\onlycmyk` is declared.
+and it is used in \^`\colordef` or if it is printed when \^`\onlycmyk` is declared.
The CMYK to RGB conversion is invoked when a color is declared using \^`\setcmykcolor`
and it is used in \^`\rgbcolordef` or if it is printed when \^`\onlyrgb` is declared.
\_endinput
2020-04-22 \replstring\tmpb{+ }{+}, {- }{-} added in \colordef, bug fixed
-2020-03-18 introduced
+2020-03-18 introduced