I want to draw a picture with some text masking the background shape lines. I tried with opacity but the fill is not very nature.
\documentclass[border=5mm, convert, usenames, dvipsnames]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, calc, arrows.meta, fit}
\begin{document}
\begin{tikzpicture}
\node [draw, rectangle, minimum width=2cm, minimum height=4cm] (a) {};
\node [draw, rectangle, minimum width=2cm, minimum height=4cm, right = 1cm of a] (b) {};
\draw [->, >=latex] (a) to node [above, fill, opacity=0.2,text opacity=1] {HelloWorld} (b);
\end{tikzpicture}
\end{document}
However what I want is like this
Forget the background color, i use some image editing tool to get this. What I want is that part of rectangle shape line dissolved behind the text. I tried to use backgrounds
but it also don't work.
Is there a possible solution?
fill=white,fill opacity=1
?fill=white
will mask the arrow line below.yshift
may be added as a workaround. But I am wondering if there are some elegant way of "fill of no color", it is better that it only mask the lines intersecting with the text\documentclass[border=5mm, convert, usenames, dvipsnames]{standalone} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \node [draw, rectangle, minimum width=2cm, minimum height=4cm] (a) {}; \node [draw, rectangle, minimum width=2cm, minimum height=4cm, right = 1cm of a] (b) {}; \path (a) to node [above, fill=white] {HelloWorld} (b); \draw [-latex] (a) to (b); \end{tikzpicture} \end{document}
fill=white
can be replaced with things likefill=nocolor
so that I can use the generated png in any color backgroundsave path
anduse path
(from [this answer](ttps://tex.stackexchange.com/a/38995/121799)) to define thereverseclip
trick (see this answer) to spare out the node when drawing the boxes. A correspondingERASER
style has been defined here.