summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-bck.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-bck.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/node-bck.mkiv71
1 files changed, 44 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-bck.mkiv b/Master/texmf-dist/tex/context/base/node-bck.mkiv
index 88fb390a9ed..858bd40b76f 100644
--- a/Master/texmf-dist/tex/context/base/node-bck.mkiv
+++ b/Master/texmf-dist/tex/context/base/node-bck.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Backgrounds,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright=PRAGMA]
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -20,53 +20,70 @@
\registerctxluafile{node-bck}{1.001}
-\def\doinitializeboxbackgrounds
+\def\node_backgrounds_boxes_initialize % will move to lua
{\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.backgrounds")}%
- \glet\doinitializeboxbackgrounds\donothing}
-
-%D Box helpers:
+ \glet\node_backgrounds_boxes_initialize\donothing}
% \backgroundvbox[green] {\input tufte } \par
% \backgroundvbox[blue] {\input ward } \par
% \backgroundvbox[red] {\input knuth } \par
% \backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par
-\def\doaddbackgroundtobox#1[#2]%
- {\begingroup\doinitializeboxbackgrounds\faststartcolor[#2]%
- \normalexpanded{\noexpand\faststopcolor\endgroup#1
- attr \backgroundattribute \plusone
- attr \colormodelattribute \the\attribute\colormodelattribute
- attr \colorattribute \the\attribute\colorattribute
- attr \transparencyattribute \the\attribute\transparencyattribute}}
-
-\def\backgroundvbox{\doaddbackgroundtobox\vbox}
-\def\backgroundvtop{\doaddbackgroundtobox\vtop}
-\def\backgroundhbox{\doaddbackgroundtobox\hbox}
-
\def\colorattr#1%
- {\ifcsname(cs:\currentpalet#1)\endcsname
- \thecolorattr{\currentpalet#1}%
- \else\ifcsname(cs:#1)\endcsname
+ {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
+ \thecolorattr{\currentcolorprefix#1}%
+ \else\ifcsname\??colorattribute#1\endcsname
\thecolorattr{#1}%
\fi\fi}
\def\thecolorattr#1%
{attr \colormodelattribute \attribute\colormodelattribute
- attr \colorattribute \csname(cs:#1)\endcsname
- attr \transparencyattribute \csname(ts:#1)\endcsname}
+ attr \colorattribute \csname\??colorattribute #1\endcsname
+ attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\backgroundcolorattr#1%
- {\ifcsname(cs:\currentpalet#1)\endcsname
- \thebackgroundcolorattr{\currentpalet#1}%
- \else\ifcsname(cs:#1)\endcsname
+ {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
+ \thebackgroundcolorattr{\currentcolorprefix#1}%
+ \else\ifcsname\??colorattribute#1\endcsname
\thebackgroundcolorattr{#1}%
\fi\fi}
\def\thebackgroundcolorattr#1%
{attr \backgroundattribute \plusone
attr \colormodelattribute \attribute\colormodelattribute
- attr \colorattribute \csname(cs:#1)\endcsname
- attr \transparencyattribute \csname(ts:#1)\endcsname}
+ attr \colorattribute \csname\??colorattribute#1\endcsname
+ attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
+
+\unexpanded\def\backgroundhbox{\node_backgrounds_boxes_add\hbox}
+\unexpanded\def\backgroundvbox{\node_backgrounds_boxes_add\vbox}
+\unexpanded\def\backgroundvtop{\node_backgrounds_boxes_add\vtop}
+
+% \def\node_backgrounds_boxes_add#1[#2]%
+% {\begingroup
+% \node_backgrounds_boxes_initialize
+% \dousecolorparameter{#2}%
+% \normalexpanded{\endgroup#1
+% attr \backgroundattribute \plusone
+% attr \colormodelattribute \the\attribute\colormodelattribute
+% attr \colorattribute \the\attribute\colorattribute
+% attr \transparencyattribute \the\attribute\transparencyattribute}}
+%
+% more efficient:
+
+\def\node_backgrounds_boxes_add#1[#2]%
+ {\node_backgrounds_boxes_initialize
+ #1\backgroundcolorattr{#2}}
+
+% less argument carry over:
+%
+% \def\node_backgrounds_boxes_add#1[#2]%
+% {\node_backgrounds_boxes_initialize#1%
+% \ifcsname\??colorattribute\currentcolorprefix#2\endcsname
+% \thebackgroundcolorattr{\currentcolorprefix#2}%
+% \else\ifcsname\??colorattribute#2\endcsname
+% \thebackgroundcolorattr{#2}%
+% \fi\fi}
+
% \def\backgroundvbox[#1]{\vbox \backgroundcolorattr{#1}}
% \def\backgroundvtop[#1]{\vtop \backgroundcolorattr{#1}}