node-bck.mkxl /size: 3255 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=node-bck,
3%D        version=2009.06.08,
4%D          title=\CONTEXT\ Node Macros,
5%D       subtitle=Backgrounds,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Node Support / Backgrounds}
15
16%D This is first attempt to replacing backgrounds in a few tables
17%D mechanisms. When used more frequently, we can store the color
18%D spec in the attribute.
19
20\unprotect
21
22\registerctxluafile{node-bck}{autosuffix}
23
24% \backgroundvbox[green] {\input tufte } \par
25% \backgroundvbox[blue]  {\input ward } \par
26% \backgroundvbox[red]   {\input knuth } \par
27% \backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par
28
29% todo: use new register feature (but not used that much so ...)
30
31\permanent\def\colorattr#1%
32  {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
33     \node_backgrounds_thecolorattr{\currentcolorprefix#1}%
34   \orelse\ifcsname\??colorattribute#1\endcsname
35     \node_backgrounds_thecolorattr{#1}%
36   \fi}
37
38\def\node_backgrounds_thecolorattr#1%
39  {attr \colormodelattribute   \c_attr_colormodel
40   attr \colorattribute        \lastnamedcs
41   attr \transparencyattribute \rawtransparencyattribute{#1} } % can be optimized
42
43\permanent\def\thecolorattr#1%
44  {attr \colormodelattribute   \c_attr_colormodel
45   attr \colorattribute        \csname\??colorattribute#1\endcsname
46   attr \transparencyattribute \rawtransparencyattribute{#1} } % can be optimized
47
48\permanent\def\backgroundcolorattr#1%
49  {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
50     \node_backgrounds_thebackgroundcolorattr{\currentcolorprefix#1}%
51   \orelse\ifcsname\??colorattribute#1\endcsname
52     \node_backgrounds_thebackgroundcolorattr{#1}%
53   \fi}
54
55\permanent\def\thebackgroundcolorattr#1%
56  {attr \backgroundattribute      \plusone
57   attr \colormodelattribute      \c_attr_colormodel
58   attr \colorattribute           \csname\??colorattribute#1\endcsname
59   attr \transparencyattribute    \rawtransparencyattribute{#1} } % can be optimized
60
61\def\node_backgrounds_thebackgroundcolorattr#1%
62  {attr \backgroundattribute      \plusone
63   attr \colormodelattribute      \c_attr_colormodel
64   attr \colorattribute           \lastnamedcs
65   attr \transparencyattribute    \rawtransparencyattribute{#1} } % can be optimized
66
67\permanent\def\thealignbackgroundcolorattr#1%
68  {attr \alignbackgroundattribute \plusone
69   attr \colormodelattribute      \c_attr_colormodel
70   attr \colorattribute           \csname\??colorattribute#1\endcsname
71   attr \transparencyattribute    \rawtransparencyattribute{#1} } % can be optimized
72
73\permanent\protected\def\backgroundhbox{\node_backgrounds_boxes_add\hbox}
74\permanent\protected\def\backgroundvbox{\node_backgrounds_boxes_add\vbox}
75\permanent\protected\def\backgroundvtop{\node_backgrounds_boxes_add\vtop}
76\permanent\protected\def\backgroundline{\dontleavehmode\node_backgrounds_boxes_add\hbox}
77
78\def\node_backgrounds_boxes_add#1[#2]%
79  {\localcontrolled{\clf_enablebackgroundboxes}% permits assignment
80   #1\backgroundcolorattr{#2}}
81
82\protect \endinput
83