我曾尝试使用 tikz 复制徽标。如您所见,徽标由一个圆圈内的七个三角形组成,凹边朝向圆圈的中心。为此,我绘制了三角形并在中心叠加了一个白色圆圈。这有效,但前提是背景是白色的。我很想让它透明
我希望使用剪辑结合奇偶规则来完成这项工作,但这似乎不可能,所以我不确定如何以简单、有效的方式做到这一点。
\definecolor{RFFgray}{HTML}{62615a}
\definecolor{RFFgreen}{HTML}{91b947}
\begin{tikzpicture}
\foreach \i in {90,141.4,192.86,244.29,295.71,347.14}
{
\draw[fill,RFFgray] (\i:1)--++(122+\i:.5)--($(\i:1)+(\i-122:.5)$)--cycle;
}
\draw[fill,RFFgreen] (38.57:1)--++(122+38.57:.5)--($(38.57:1)+(38.57-122:.5)$)--cycle;
\draw[white,fill](0,0)circle(.87);
\end{tikzpicture}
答案1
您始终可以只绘制所需的部分:‘三角形’。例如,使用\pic
:
\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{calc}
\tikzset
{%
pics/my triangle/.style={%
code={\path[pic actions] (0:1) -- (180/7:0.87) arc (180/7:-180/7:0.87) -- cycle;}
}
}
\begin{document}
\definecolor{RFFgray} {HTML}{62615a}
\definecolor{RFFgreen}{HTML}{91b947}
\begin{tikzpicture}
\foreach \i in {1,3,4,...,7}
\pic[rotate=-360/7+360*\i/7,fill=RFFgray] {my triangle};
\pic[rotate=360/7,fill=RFFgreen] {my triangle};
\end{tikzpicture}
\end{document}
编辑:正如 Anis 所建议的,在这里您可以看到“透明度”。当然,这里没有任何透明的东西。只有您能看到的东西才会被绘制出来。
\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{calc}
\tikzset
{%
pics/my triangle/.style={%
code={\path[pic actions] (0:1) -- (180/7:0.87) arc (180/7:-180/7:0.87) -- cycle;}
}
}
\begin{document}
\begin{tikzpicture}
\node {\includegraphics[width=3.5cm]{example-image-duck}};
\foreach \i in {1,3,4,...,7}
\pic[rotate=-360/7+360*\i/7,fill=blue!50] {my triangle};
\pic[rotate=360/7,fill=red!50] {my triangle};
\end{tikzpicture}
\end{document}
答案2
它使用 TikZ 命令arc
。有两个常量\cR
和\cA
控制三角形的尺寸,以防您需要修改它们。
您还可以修改三角形的数量。
代码
\documentclass[11pt, margin=.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\definecolor{RFFgray}{HTML}{62615a}
\definecolor{RFFgreen}{HTML}{91b947}
\begin{tikzpicture}[evaluate={%
integer \N; \N = 7;
real \r, \cR, \d, \cD;
\r = 1;
\cR = .87;
\cD = .33;
\d = \cD*360/\N;
}]
\fill[violet!50] (-135: \r+.6) rectangle (45: \r+.6);
\foreach \i [parse=true, evaluate=\i as \a using {(\i -1)*(360/\N) +90}]
in {1, 2, ..., \N-1}{%
\filldraw[RFFgray]
(\a: \r) -- (\a -\d: \r*\cR) arc (\a -\d: \a +\d: \r*\cR) -- (\a: \r);
}
\filldraw[RFFgreen]
(90 -360/\N: \r) -- (90 -360/\N -\d: \r*\cR)
arc (90 -360/\N -\d: 90 -360/\N +\d: \r*\cR) -- (90 -360/\N: \r);
\begin{scope}[xshift=2.5cm]
\foreach \i [parse=true, evaluate=\i as \a using {(\i -1)*(360/\N) +90}]
in {1, 2, ..., \N-1}{%
\filldraw[RFFgray]
(\a: \r) -- (\a -\d: \r*\cR) arc (\a -\d: \a +\d: \r*\cR) -- (\a: \r);
}
\filldraw[RFFgreen]
(90 -360/\N: \r) -- (90 -360/\N -\d: \r*\cR)
arc (90 -360/\N -\d: 90 -360/\N +\d: \r*\cR) -- (90 -360/\N: \r);
\end{scope}
\end{tikzpicture}
\end{document}
答案3
您可以使用倒置的剪辑,例如https://tex.stackexchange.com/a/138918/36296
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
%\pagecolor{red}
\tikzset{
invclip/.style={
clip, insert path={{(current page.north east) rectangle (current page.south west)}}},
}
\begin{document}
\definecolor{RFFgray}{HTML}{62615a}
\definecolor{RFFgreen}{HTML}{91b947}
\begin{tikzpicture}
\begin{pgfinterruptboundingbox}
\path[invclip] (0,0)circle(.87);
\end{pgfinterruptboundingbox}
\foreach \i in {90,141.4,192.86,244.29,295.71,347.14}
{
\draw[fill,RFFgray] (\i:1)--++(122+\i:.5)--($(\i:1)+(\i-122:.5)$)--cycle;
}
\draw[fill,RFFgreen] (38.57:1)--++(122+38.57:.5)--($(38.57:1)+(38.57-122:.5)$)--cycle;
\end{tikzpicture}
\end{document}