具有透明度和边界的通用标注样式

具有透明度和边界的通用标注样式

我希望有一种通用的标注样式,可以与边界、透明度、多个指针和不同大小的指针配合使用。类似于此解决方案

克皮姆 解决方案在多个指针的情况下效果很好。例如:

\documentclass[border=5mm]{standalone}
\usepackage{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
decorations.pathreplacing,
shadows.blur}
\definecolor{left} {HTML}{001528}
\tikzset{
add path/.style = {
decoration={show path construction,
moveto code={
\xdef\savedpath{\savedpath (\tikzinputsegmentfirst)}
},
lineto code={
\xdef\savedpath{\savedpath -- (\tikzinputsegmentlast)}
},
curveto code={
\xdef\savedpath{\savedpath .. controls (\tikzinputsegmentsupporta) and 
(\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast)}
 },
 closepath code={
 \xdef\savedpath{\savedpath -- cycle}}},decorate},store path/.style = {add 
 path},
 store path/.prefix code={\xdef\savedpath{}},
 callouts/.style={
 store path,
 append after command={
 foreach \target in {#1}{
 ($(callout)!2pt!-90:\target$)--\target --($(callout)!2pt!90:\target$)
 } \savedpath},
 alias=callout},
 custom style/.style={fill=black!20,text=,},}
\begin{document}
\begin{tikzpicture}
\path[custom style] (7.5,-11) 
node[rounded corners,align=left,callouts={(9,-12),(9,-10)}]{blah, blah};
\end{tikzpicture} 
\end{document}

在此处输入图片描述

但是,一旦您尝试将自定义样式更改为具有透明度和边界的标注,结果就会非常丑陋。

\documentclass[border=5mm]{standalone}
\usepackage{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
decorations.pathreplacing,
shadows.blur}
\definecolor{left} {HTML}{001528}
\tikzset{
add path/.style = {
decoration={show path construction,
moveto code={
\xdef\savedpath{\savedpath (\tikzinputsegmentfirst)}
},
lineto code={
\xdef\savedpath{\savedpath -- (\tikzinputsegmentlast)}
},
curveto code={
\xdef\savedpath{\savedpath .. controls (\tikzinputsegmentsupporta) and 
(\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast)}
 },
 closepath code={
 \xdef\savedpath{\savedpath -- cycle}}},decorate},store path/.style = {add 
 path},
 store path/.prefix code={\xdef\savedpath{}},
 callouts/.style={
 store path,
 append after command={
 foreach \target in {#1}{
 ($(callout)!2pt!-90:\target$)--\target --($(callout)!2pt!90:\target$)
 } \savedpath},
 alias=callout},
 custom style/.style={fill=black!20,text=,},}
\begin{document}
\begin{tikzpicture}
\path[custom style] (7.5,-11) 
node[rounded corners,align=left,callouts={(9,-12),(9,-10)}]{blah, blah};
\end{tikzpicture} 
\end{document}

在此处输入图片描述

问题:如上所述,我的问题是是否存在具有透明度、边界和不同大小指针的类似解决方案。

答案1

这是一个非常简单的建议,当然不是一个完整的解决方案。Kpym 的解决方案在我看来,它特别有吸引力,因为它不使用任何复杂的方法,而且有效。当然,它有你提到的局限性。解决方案作者:Qrrbrbirlbel按符号 1当然很有创意。他们的主要观察是将几个标注放在一起。一种方法是采用 Kpym 的解决方案并采纳其他人的理念。通过一点复制和粘贴,人们几乎可以得到想要的一切。基本技巧是绘制一个线宽较大的标注,然后draw在其上绘制第二个不绘制但有填充的标注。

\documentclass[border=5mm]{standalone}
\usepackage{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
decorations.pathreplacing,
shadows.blur}
\definecolor{left} {HTML}{001528}
\tikzset{
add path/.style = {
decoration={show path construction,
moveto code={
\xdef\savedpath{\savedpath (\tikzinputsegmentfirst)}
},
lineto code={
\xdef\savedpath{\savedpath -- (\tikzinputsegmentlast)}
},
curveto code={
\xdef\savedpath{\savedpath .. controls (\tikzinputsegmentsupporta) and 
(\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast)}
 },
 closepath code={
 \xdef\savedpath{\savedpath -- cycle}}},decorate},store path/.style = {add 
 path},
 store path/.prefix code={\xdef\savedpath{}},
 callouts/.style={
 store path,
 append after command={
 foreach \target in {#1}{
 ($(callout)!2pt!-90:\target$)--\target --($(callout)!2pt!90:\target$)
 } \savedpath},
 alias=callout},
 custom style/.style={},}
\begin{document}
\begin{tikzpicture}
% first
\path[draw,very thick,line join=round] (7.5,-3) 
node[rounded corners,align=left,callouts={(9,-4),(9,-2)}]{blah, blah};
\path[fill=white] (7.5,-3) 
node[rounded corners,align=left,callouts={(9,-4),(9,-2)}]{blah, blah};
% second
\path[draw,very thick,line join=round,blur shadow] (7.5,-6) 
node[rounded corners,align=left,callouts={(9,-7),(9,-5)}]{blah, blah};
\path[fill=white] (7.5,-6) 
node[rounded corners,align=left,callouts={(9,-7),(9,-5)}]{blah, blah};
\path[fill=blue,opacity=0.3] (7.5,-6) 
node[rounded corners,align=left,callouts={(9,-7),(9,-5)}]{blah, blah};
\end{tikzpicture} 
\end{document}

在此处输入图片描述

当然,你可以把它做成一个宏,这样就不用再复制粘贴了,甚至可以做成一个 TiZ 风格通过使用保存路径/使用路径技巧。如果你要求我这么做,我很乐意解释这一点。

相关内容