# [NTG-context] colored box background

Taco Hoekwater taco at elvenkind.com
Fri Jul 14 11:49:56 CEST 2006


Hans van der Meer wrote:
> Say I have a box, e.g. \setbox\thebox=\vbox{....} with dimensions
> \wd\thebox etc.
> What then is the most efficient and economic (in terms of complexity and
> speed) way to generate a colored background for it?

If you really want your code to be as efficient and minimalist as
possible, you are better of with the plain format than with ConTeXt
in any case. Personally I prefer to optimize on complexity and

That said, metapost graphics are, in general, heavier than \framed.
If you really need thousands and thousands of those boxes, a macro
like:

\def\bgcolorthebox#1%
{\dontleavehmode
\rlap{\color[#]
{\vrule height \ht\thebox
depth \dp\thebox
width \wd\thebox}}%
\box\thebox }

can help. But if it is only a few, simply use \framed.

Taco