I draw images that are composed of several overlapping nodes. If I add a drop shadow
to each node, the shadow of the second node is drawn over the first node, as seen in the picture below (which consist of two cylinder
nodes drawn from bottom to top, each with a shadow):
(Thanks to zeroth for providing the image in reply to this related question. )
The documentation to TikZ states it clearly: You can apply a shadow only to a path, but not to a scope. The workaround I'm using is this:
- Create a
\foreach
loop that loops over{drop shadow,}
, thus assigning firstdrop shadow
, then the empty string to a macro, say,\s
- Use
\s
for the options of every node. (Perhaps I could append\s
toevery node
andevery path
, didn't try that yet.)
Of course the image is drawn twice in the resulting PDF, which somewhat affects rendering speed and perhaps the size of the resulting PDF. In addition, the resulting code is rather ugly. My questions are:
- Is there a clean way of achieving the desired result using a TikZ/pgf feature? Perhaps it is possible to turn a sequence of TikZ/pgf commands into a single path?
- If not:
- Is it possible to add some style parameters to nodes and paths in the first pass so that the details of the image are not rendered when drawing the shadow?
- Would it be technically feasible to implement an environment
shadowgroup
that would hide the complexity and ugliness behind that?