blob: 0e7bbb853f3333a82848fabc3af3c334582e373d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
%D \module
%D [ file=node-bck,
%D version=2009.06.08,
%D title=\CONTEXT\ Node Macros,
%D subtitle=Backgrounds,
%D author=Hans Hagen,
%D date=\currentdate,
%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
%C details.
\writestatus{loading}{ConTeXt Node Support / Backgrounds}
%D This is first attempt to replacing backgrounds in a few tables
%D mechanisms. When used more frequently, we can store the color
%D spec in the attribute.
\unprotect
\registerctxluafile{node-bck}{optimize}
% \backgroundvbox[green] {\input tufte } \par
% \backgroundvbox[blue] {\input ward } \par
% \backgroundvbox[red] {\input knuth } \par
% \backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par
\def\colorattr#1%
{\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
\node_backgrounds_thecolorattr{\currentcolorprefix#1}%
\else\ifcsname\??colorattribute#1\endcsname
\node_backgrounds_thecolorattr{#1}%
\fi\fi}
\def\node_backgrounds_thecolorattr#1%
{attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \lastnamedcs
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\thecolorattr#1%
{attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \csname\??colorattribute#1\endcsname
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\backgroundcolorattr#1%
{\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
\node_backgrounds_thebackgroundcolorattr{\currentcolorprefix#1}%
\else\ifcsname\??colorattribute#1\endcsname
\node_backgrounds_thebackgroundcolorattr{#1}%
\fi\fi}
\def\thebackgroundcolorattr#1%
{attr \backgroundattribute \plusone
attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \csname\??colorattribute#1\endcsname
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\node_backgrounds_thebackgroundcolorattr#1%
{attr \backgroundattribute \plusone
attr \colormodelattribute \c_attr_colormodel
attr \colorattribute \lastnamedcs
attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized
\def\thealignbackgroundcolorattr#1%
{attr \alignbackgroundattribute \plusone
attr \colormodelattribute \c_attr_colormodel
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}
\unexpanded\def\backgroundline{\dontleavehmode
\node_backgrounds_boxes_add\hbox}
% \def\node_backgrounds_boxes_add#1[#2]%
% {\begingroup
% \clf_enablebackgroundboxes
% \dousecolorparameter{#2}%
% \normalexpanded{\endgroup#1
% attr \backgroundattribute \plusone
% attr \colormodelattribute \the\c_attr_colormodel
% attr \colorattribute \the\c_attr_color
% attr \transparencyattribute \the\c_attr_transparency}}
%
% more efficient:
\def\node_backgrounds_boxes_add#1[#2]%
{\clf_enablebackgroundboxes
#1\backgroundcolorattr{#2}}
\protect \endinput
|