1

I want to be able to iterate (left to right, bottom to top) the bounding box of a specific path, (I am guessing) one that has been "saved" using spath3. Why? I want to use it to fill the path with a custom fill but do not want to iterate outside of the bounding box (yes, still using clip).

So I need access to the bounding box of an arbitrary path.

The closest thing I can see is: Tikz: Shading a path without any filling

ggg
  • 11
  • 1
  • In general, you can only find approximate solutions. Why? The envelope of a cubic Bezier curve is in general not composed of cubic Bezier curves, let alone single Bezier curves for the "upper" boundary. –  May 04 '21 at 20:35
  • Understood. But what about a path that is made up of only straight segments. Can the bounding box of this be obtained in some manner, either through spath3 or some other package? – ggg May 05 '21 at 12:40
  • I'd assume that you could use a decoration, e.g. https://tex.stackexchange.com/a/495140 seems to do such things. –  May 05 '21 at 16:04
  • Would \begin{scope}[local bounding box=foo] <add path here> \end{scope} be helpful? Then foo becomes a node that fits around the path, and you can access its anchors. – Torbjørn T. Jun 09 '21 at 21:51

1 Answers1

1

Why don't use a knockout transparency group:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade [left color=red,right color=blue] (-2,-1) rectangle (2,1);
\begin{scope}[transparency group=knockout]
\fill [white] (-1.9,-.9) rectangle (1.9,.9);
\node [opacity=0,font=\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries]
{Ti\emph{k}Z};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Note: example taken from the PGFManual. Not all renderers support it (the image above is with Adobe reader DC. It don't work with the render of texstudio)

vi pa
  • 3,394