On Thu, 8 Nov 2012, Hans Hagen wrote:

(just to illustrate that an overlay can be used for anything)

This prompted me to finish testing what I had been thinking about for a while.

In most cases, metapost is sufficient for drawing backgrounds, but occasionally using tikz is nicer. For example, when tikz provides a solution that is not available in metapost (e.g., drawing "snake" paths), or extremely difficult to get right in metapost (drawing shadows).

As Hans said, overlays can be used for anything, including tikz background. Here is a proof of concept implementation:

\usemodule[tikz]
\usetikzlibrary[decorations.pathmorphing]

\def\TIKZdecorationoverlay
    {\starttikzpicture
        \expanded{\draw[\overlaylinecolor, line width=\overlaylinewidth,
              decorate, decoration={\framedparameter{decoration}}]
              (0,0)--(\overlaywidth,0) --
              (\overlaywidth,\overlayheight) -- (0,\overlayheight) -- cycle;}
     \stoptikzpicture}

\defineoverlay[decoration][\TIKZdecorationoverlay]

\setupframed
  [decoration=snake]

\starttext

\framed[frame=off, rulethickness=3bp, background=decoration,
         backgroundoffset=3mm, framecolor=red, align=normal]
         {\input ward \endgraf}

\blank[2*big]

\externalfigure
  [cow]
  [frame=off, frameoffset=5pt, backgroundoffset=frame,
  background=decoration,
  decoration={coil, amplitude=4pt, segment length=5pt}]

\stoptext

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to