diff options
Diffstat (limited to 'macros/optex/base/colors.opm')
-rw-r--r-- | macros/optex/base/colors.opm | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/macros/optex/base/colors.opm b/macros/optex/base/colors.opm index 6ef8fc9dcf..36afcb3862 100644 --- a/macros/optex/base/colors.opm +++ b/macros/optex/base/colors.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \colordef {Colors <2021-07-16>} % preloaded in format +\_codedecl \colordef {Colors <2022-03-07>} % preloaded in format \_doc ----------------------------- The basic colors in CMYK @@ -72,14 +72,11 @@ \_color:<attribute-value> ... expands to <data> <fill-op> \_color-s:<attribute-value> ... expands to <data> <stroke-op> \endtt - The \`\_resetcolor` un-sets the color attribute, it means that default - color (black) shall be used. \_cod ----------------------------- \_newattribute \_colorattr \_newcount \_colorcnt \_colorcnt=1 % allocations start at 1 \_protected\_def\_setcolor{\_colorprefix\_colorattr=\_translatecolor} -\_def\_resetcolor{\_colorattr=-"7FFFFFFF } \_def\_translatecolor#1#2#3{\_ifcsname _color::#1 #2\_endcsname\_lastnamedcs\_relax \_else \_colorcnt @@ -108,6 +105,41 @@ \_localcolor \_doc ----------------------------- + The attribute \`\_transpattr` is allocated and set by the + \`\transparency``<number>` macro. If such level of the tranparency was + never used in the document then + \^`\addextgstate{tr<number>}`\code{\{<</ca X /CA X>>\}} is applied + (where `X` is `(255-<number>)/255`). + This information is used when shipout is processed (similarly as colors). + It means `/tr<number> gs` is inserted when the attribute is changed.\nl + \`\_resetattrs` resets the \^`\_colorattr` and \^`\_transpattr` + to their initial value `-"7FFFFFFF`. + \_cod ----------------------------- + +\_newattribute\_transpattr +\_def\_transparency {\_afterassignment\_transparencyA \_transpattr} +\_def\_transparencyA{% + \_ifnum\_transpattr<1 \_transpattr=\_noattr \_fi + \_ifnum\_transpattr>255 \_opwarning{\_noexpand\transparency > 255 not allowed}% + \_transpattr=\_noattr + \_else + \_ifcsname _transp:\_the\_transpattr\_endcsname \_else + \_edef\_transpv{\_expr{(255-\_the\_transpattr)/255}}% + \_addextgstate{tr\_the\_transpattr}{<</ca \_transpv\_space /CA \_transpv>>}% + \_sxdef{_transp:\_the\_transpattr}{}% + \_ifcsname _transp:0\_endcsname \_else + \_addextgstate{tr0}{<</ca 1 /CA 1>>}% + \_sxdef{_transp:0}{}% + \_fi + \_fi + \_fi +} +\_def\_thetransparency{\_ifnum \_transpattr=-"7FFFFFFF 0\_else \_the\_transpattr \_fi} +\_def\_resetattrs{\_colorattr=\_noattr \_transpattr=\_noattr} + +\_public \transparency \thetransparency ; + + \_doc ----------------------------- 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 @@ -411,6 +443,8 @@ and it is used in \^`\rgbcolordef` or if it is printed when \^`\onlyrgb` is decl \_endinput +2022-03-07 \_resetattrs instead \_resetcolor +2022-03-05 \transparency added 2021-07-16 colors reimplemented, now they are based on attributes 2021-05-28 \rgbcmykmap introduced 2020-04-22 \replstring\tmpb{+ }{+}, {- }{-} added in \colordef, bug fixed |