在 tikz 中旋转花括号

在 tikz 中旋转花括号

我找到了这个问题展示了如何在 tikz 中绘制花括号并使用装饰来镜像它们。但是,如何将它们旋转任意角度?。

答案1

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}
\draw[help lines] (-6,-6) grid (6,6);
\foreach \x in {0,36,72,...,324}
\draw [decorate,decoration={brace,amplitude=10pt},rotate=\x] (0.5,0.5) -- (0.5,5.0);
\end{tikzpicture}
\end{document}

enter image description here

你也可以rotate around一點。

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}
\draw[help lines] (-6,-6) grid (6,6);
\foreach \x in {0,36,72,...,324}
\draw [decorate,decoration={brace,amplitude=10pt},rotate around={\x:(0.5,0.5)},=\x] (0.5,0.5) -- (0.5,5.0);
\end{tikzpicture}
\end{document}

enter image description here

enter image description here

答案2

可以猜测的是:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[scale=1,rotate=60] % the only change
\draw[thick] (-1,0) rectangle +(6,7.5);
\filldraw[thick, top color=white,bottom color=red!50!] (0.5,0) rectangle node{$N_S$} +(1.3,0.5);
\filldraw[thick, top color=white,bottom color=red!50!] (2.2,0) rectangle node{$N_L$} +(1.3,0.65);
\filldraw[top color=white,bottom color=blue!50!] (0.5,0.5) rectangle node{$P_{1}$} +(1.3,0.5);
\filldraw[top color=white,bottom color=blue!50!] (2.2,0.65) rectangle node{$P_{2}$} +(1.3,1.0);
\filldraw[top color=white,bottom color=blue!50!] (0.5,1.0) rectangle node{$P_{3}$} +(1.3,1.5);
\filldraw[top color=white,bottom color=blue!50!] (2.2,1.65) rectangle node{$P_{4}$} +(1.3,2.0);
\filldraw[top color=white,bottom color=blue!50!] (0.5,2.5) rectangle node{$P_{5}$} +(1.3,2.5);
\filldraw[top color=white,bottom color=blue!50!] (2.2,3.65) rectangle node{$P_{6}$} +(1.3,3.0);
\draw [decorate,decoration={brace,amplitude=10pt},xshift=-4pt,yshift=0pt]
(0.5,0.5) -- (0.5,5.0) node [black,midway,xshift=-0.6cm] 
{\footnotesize $P_1$};
\draw [decorate,decoration={brace,amplitude=10pt},xshift=-4pt,yshift=0pt]
(3.5,0.65) -- (3.5,6.5)node [black,midway,xshift=9pt] {\footnotesize
$P_2$};
\end{tikzpicture}
\end{document}

enter image description here

相关内容