![如何使用 TikZ 以不同的比例用两种颜色填充形状?](https://linux22.com/image/429263/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20TikZ%20%E4%BB%A5%E4%B8%8D%E5%90%8C%E7%9A%84%E6%AF%94%E4%BE%8B%E7%94%A8%E4%B8%A4%E7%A7%8D%E9%A2%9C%E8%89%B2%E5%A1%AB%E5%85%85%E5%BD%A2%E7%8A%B6%EF%BC%9F.png)
答案1
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows,shadings,shapes.symbols, calc}
\begin{document}
\begin{tikzpicture}[my node/.style={draw, cloud, cloud ignores aspect, }]
\node[my node] (a1) {Text};
\end{tikzpicture}
\begin{tikzpicture}[fill fraction/.style n args={2}{path picture={
\fill[#1] (path picture bounding box.south west) rectangle
($(path picture bounding box.north west)!#2!(path picture bounding box.north east)$);}}]
\draw (4, 0) node[cloud, cloud ignores aspect,draw,fill=blue, fill fraction={green}{0.7}] {Some
other text};
\end{tikzpicture}
\end{document}
编辑
长文本破坏了云的形状,因此需要编辑
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows,shadings,shapes.symbols, calc}
\begin{document}
\begin{tikzpicture}[my node/.style={draw, cloud, cloud ignores aspect, }]
\node[my node] (a1) {Text};
\end{tikzpicture}
\begin{tikzpicture}[fill fraction/.style n args={2}{path picture={
\fill[#1] (path picture bounding box.south west) rectangle
($(path picture bounding box.north west)!#2!(path picture bounding box.north east)$);}}]
\draw (4, 0) node[cloud, cloud ignores aspect,draw,fill=blue, fill fraction={green}{0.7}] {text};
\end{tikzpicture}
\end{document}
结果是