norbusan / pgf-blur

Development of pg-blur package
416 stars 0 forks source link

Shadows, image externalization and bounding boxes #1

Open fbouchez opened 5 years ago

fbouchez commented 5 years ago

As far as I understood, the blurred shadows do not extend the bounding box of the picture. In my case, I need to externalize tikz pictures. However, the shadows are "cropped" for nodes that are near the bottom or the right of the picture.

I currently use a macro to extend the current bounding box but : 1- I need to manually choose the dimensions 2- those dimensions change if the scale of the picture is changed 3- not all pictures have a node at the bottom or the right

Is there a way to include the shadows in the bounding box ?

Thanks

fbouchez commented 5 years ago

Note that I now include the zoom factor so that it works for any scale. But I still need to manually set the dimensions used to increase the bounding box (shadow x/yshift + shadow radius).

\newcommand{\getzoomfactor}{% \pgfgettransformentries{\myxscale}{\@tempa}{\@tempa}{\myyscale}{\@tempa}{\@tempa} \gdef\zoomfactor{\myxscale} } \newcommand\increase@boundingbox[1]{% \path [use as bounding box] (current bounding box.south east) ++ (#1);% } \newcommand\increase@shadowboundingboxgen[2]{% %% blurred shadows \getzoomfactor% \def\xinc{0}% \ifnum#1>0% \def\xinc{1.1ex/\zoomfactor-\pgflinewidth/2/\zoomfactor}% \fi% \ifnum#2>0% \def\yinc{-0.9ex/\zoomfactor+\pgflinewidth/2/\zoomfactor}% \fi% \increase@boundingbox{\xinc,\yinc}% }

\newcommand\increaseshadowboundingbox{% \increase@shadowboundingboxgen{1}{1}% } \newcommand\increasebottomshadowboundingbox{% \increase@shadowboundingboxgen{0}{1}% } \newcommand\increaserightshadowboundingbox{% \increase@shadowboundingboxgen{1}{0}% }

norbusan commented 5 years ago

The current code restores the original bounding box, that is true. When removing the restore code I get an image like this: Screenshot from 2019-04-01 16-38-33 from the code

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[inner frame sep=0mm,framed]
\node[fill=white, draw=red, blur shadow] at (4,0.5) {Node};
\end{tikzpicture}
\end{document}

I guess you would like to have that in this case the left and top bb is as with the original, and only the lower and right bb is adjusted, correct?

fbouchez commented 5 years ago

Correct :-)

norbusan commented 5 years ago

Hmmm, tricky ... because one can throw the shadow in arbitrary directions ... need to think about it (it is not my code - I just maintain it now)

norbusan commented 5 years ago

And in addition, if the shadow protrudes over the top edge, it should not be cut off, of course ...