用 tikz 制作党徽、党旗、国旗和团旗

规定

过程

一开始是按照《中国共产党党旗党徽制作和使用的若干规定》一步一步画好圆和直线(注意横纵坐标的方向),然后根据 intersections 库和肉眼确定交点坐标和圆弧的角度,得到初稿

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=0.6]
\draw[gray] (1,-1) grid (33,-33);
\path[draw,gray,name path=EF] (29,-33) -- (33,-29);
\path[draw,gray,name path=ER] (29,-33) -- ++ (135:35);
\path[draw,gray,name path=FV] (33,-29) -- ++ (135:35);
\path[draw,gray,name path=GH] (8.5,-18.5) ++ (45:-10) -- ++ (45:33);
\path[draw,gray,name path=GI] (8.5,-18.5) -- (4,-14);
\path[draw,gray,name path=HJ] (19.5,-7.5) -- (17,-5);
\path[draw,gray,name path=IL] (4,-14) -- ++ (45:15);
\path[draw,gray,name path=KJL] (13.5,-1) circle (5.315);
\path[draw,gray,name path=NO] (17,-17) circle (16);
\path[draw,gray,name path=OQ] (17,-15) circle (18);
\path[draw,gray,name path=NS] (11,-16.5) circle (16.62077);
\path[draw,gray,name path=TS] (11,-16.5) -- ++ (20,0);
\path[draw,gray,name path=SU] (16.5,-16.5) circle (11.12077);
\path[draw,gray,name path=UW] (16.5,-11) circle (16.62077);
\path[draw,gray,name path=XYZ] (3.5,-30.5) circle (2.5);
\path[draw,gray,name path=YY] (6,-30) ++ (45:-0.5) -- ++ (45:3);
\path[draw,gray,name path=ZZ] (4,-28) ++ (45:-0.5) -- ++ (45:3);
\path[name intersections={of=EF and ER, by=E}];
\path[name intersections={of=EF and FV, by=F}];
\path[name intersections={of=NO and FV, by=F1}];
\path[name intersections={of=GH and UW, by=W}];
\path[name intersections={of=GH and OQ, by=Q}];
\path[name intersections={of=ZZ and OQ, by=Z1}];
\path[name intersections={of=ZZ and XYZ, by=Z}];
\path[name intersections={of=YY and XYZ, by=Y}];
\path[name intersections={of=YY and OQ, by=Y1}];
\path[name intersections={of=NO and ER, by=E1}];
\path[name intersections={of=SU and FV, name=F2}];
\path[name intersections={of=GH and FV, by=V}];
\path[name intersections={of=GH and HJ, by=H}];
\path[name intersections={of=KJL and HJ, by=J}];
\path[name intersections={of=KJL and IL, by=L}];
\path[name intersections={of=GI and IL, by=I}];
\path[name intersections={of=GI and GH, by=G}];
\path[name intersections={of=ER and GH, by=R}];
\path[name intersections={of=ER and SU, name=E2}];
\draw (E) -- (F) -- (F1) arc (-34.841:90:16) -- (17,-1) arc (68.838715:0:16.62077) -- (27.62077,-16.5) arc (0:-30.262:11.12077) -- (V) -- (H) -- (J) arc (-48.814:-107.27:5.315) -- (L) -- (I) -- (G) -- (R) -- (E2-2) arc (-59.78:-90:11.12077) -- (16.5,-27.62077) arc (-90:-136.18:16.62077) -- (W) -- (Q) arc (-146.26:-134.94:18) -- (Z1) -- (Z) arc (-280.6:10.485:2.5) -- (Y) -- (Y1) arc (-125.93:-90:18) -- (17,-33) arc (-90:-55.183:16) -- (E1) -- cycle;
\end{tikzpicture}
\end{document}

想将线条隐去,只需要去掉 draw 选项,即

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=0.6]
\draw[gray] (1,-1) grid (33,-33);
\path[name path=EF] (29,-33) -- (33,-29);
\path[name path=ER] (29,-33) -- ++ (135:35);
\path[name path=FV] (33,-29) -- ++ (135:35);
\path[name path=GH] (8.5,-18.5) ++ (45:-10) -- ++ (45:33);
\path[name path=GI] (8.5,-18.5) -- (4,-14);
\path[name path=HJ] (19.5,-7.5) -- (17,-5);
\path[name path=IL] (4,-14) -- ++ (45:15);
\path[name path=KJL] (13.5,-1) circle (5.315);
\path[name path=NO] (17,-17) circle (16);
\path[name path=OQ] (17,-15) circle (18);
\path[name path=NS] (11,-16.5) circle (16.62077);
\path[name path=TS] (11,-16.5) -- ++ (20,0);
\path[name path=SU] (16.5,-16.5) circle (11.12077);
\path[name path=UW] (16.5,-11) circle (16.62077);
\path[name path=XYZ] (3.5,-30.5) circle (2.5);
\path[name path=YY] (6,-30) ++ (45:-0.5) -- ++ (45:3);
\path[name path=ZZ] (4,-28) ++ (45:-0.5) -- ++ (45:3);
\path[name intersections={of=EF and ER, by=E}];
\path[name intersections={of=EF and FV, by=F}];
\path[name intersections={of=NO and FV, by=F1}];
\path[name intersections={of=GH and UW, by=W}];
\path[name intersections={of=GH and OQ, by=Q}];
\path[name intersections={of=ZZ and OQ, by=Z1}];
\path[name intersections={of=ZZ and XYZ, by=Z}];
\path[name intersections={of=YY and XYZ, by=Y}];
\path[name intersections={of=YY and OQ, by=Y1}];
\path[name intersections={of=NO and ER, by=E1}];
\path[name intersections={of=SU and FV, name=F2}];
\path[name intersections={of=GH and FV, by=V}];
\path[name intersections={of=GH and HJ, by=H}];
\path[name intersections={of=KJL and HJ, by=J}];
\path[name intersections={of=KJL and IL, by=L}];
\path[name intersections={of=GI and IL, by=I}];
\path[name intersections={of=GI and GH, by=G}];
\path[name intersections={of=ER and GH, by=R}];
\path[name intersections={of=ER and SU, name=E2}];
\draw (E) -- (F) -- (F1) arc (-34.841:90:16) -- (17,-1) arc (68.838715:0:16.62077) -- (27.62077,-16.5) arc (0:-30.262:11.12077) -- (V) -- (H) -- (J) arc (-48.814:-107.27:5.315) -- (L) -- (I) -- (G) -- (R) -- (E2-2) arc (-59.78:-90:11.12077) -- (16.5,-27.62077) arc (-90:-136.18:16.62077) -- (W) -- (Q) arc (-146.26:-134.94:18) -- (Z1) -- (Z) arc (-280.6:10.485:2.5) -- (Y) -- (Y1) arc (-125.93:-90:18) -- (17,-33) arc (-90:-55.183:16) -- (E1) -- cycle;
\end{tikzpicture}
\end{document}

党旗上色后的代码

\documentclass{standalone}
\usepackage[cmyk]{xcolor}
\definecolor{yellow}{cmyk}{0,0,1,0}
\definecolor{red}{cmyk}{0,0.88,0.84,0.07}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=0.6]
\draw[gray] (1,-1) grid (33,-33);
\path[name path=EF] (29,-33) -- (33,-29);
\path[name path=ER] (29,-33) -- ++ (135:35);
\path[name path=FV] (33,-29) -- ++ (135:35);
\path[name path=GH] (8.5,-18.5) ++ (45:-10) -- ++ (45:33);
\path[name path=GI] (8.5,-18.5) -- (4,-14);
\path[name path=HJ] (19.5,-7.5) -- (17,-5);
\path[name path=IL] (4,-14) -- ++ (45:15);
\path[name path=KJL] (13.5,-1) circle (5.315);
\path[name path=NO] (17,-17) circle (16);
\path[name path=OQ] (17,-15) circle (18);
\path[name path=NS] (11,-16.5) circle (16.62077);
\path[name path=TS] (11,-16.5) -- ++ (20,0);
\path[name path=SU] (16.5,-16.5) circle (11.12077);
\path[name path=UW] (16.5,-11) circle (16.62077);
\path[name path=XYZ] (3.5,-30.5) circle (2.5);
\path[name path=YY] (6,-30) ++ (45:-0.5) -- ++ (45:3);
\path[name path=ZZ] (4,-28) ++ (45:-0.5) -- ++ (45:3);
\path[name intersections={of=EF and ER, by=E}];
\path[name intersections={of=EF and FV, by=F}];
\path[name intersections={of=NO and FV, by=F1}];
\path[name intersections={of=GH and UW, by=W}];
\path[name intersections={of=GH and OQ, by=Q}];
\path[name intersections={of=ZZ and OQ, by=Z1}];
\path[name intersections={of=ZZ and XYZ, by=Z}];
\path[name intersections={of=YY and XYZ, by=Y}];
\path[name intersections={of=YY and OQ, by=Y1}];
\path[name intersections={of=NO and ER, by=E1}];
\path[name intersections={of=SU and FV, name=F2}];
\path[name intersections={of=GH and FV, by=V}];
\path[name intersections={of=GH and HJ, by=H}];
\path[name intersections={of=KJL and HJ, by=J}];
\path[name intersections={of=KJL and IL, by=L}];
\path[name intersections={of=GI and IL, by=I}];
\path[name intersections={of=GI and GH, by=G}];
\path[name intersections={of=ER and GH, by=R}];
\path[name intersections={of=ER and SU, name=E2}];
\filldraw[fill=red,draw=red,line width=0pt] (-15,11) rectangle (129,-85);
\filldraw[fill=yellow,draw=red,line width=0pt] (E) -- (F) -- (F1) arc (-34.841:90:16) -- (17,-1) arc (68.838715:0:16.62077) -- (27.62077,-16.5) arc (0:-30.262:11.12077) -- (V) -- (H) -- (J) arc (-48.814:-107.27:5.315) -- (L) -- (I) -- (G) -- (R) -- (E2-2) arc (-59.78:-90:11.12077) -- (16.5,-27.62077) arc (-90:-136.18:16.62077) -- (W) -- (Q) arc (-146.26:-134.94:18) -- (Z1) -- (Z) arc (-280.6:10.485:2.5) -- (Y) -- (Y1) arc (-125.93:-90:18) -- (17,-33) arc (-90:-55.183:16) -- (E1) -- cycle;
\end{tikzpicture}
\end{document}

国旗按照《中华人民共和国国旗法》先画个大五角星,然后设置宏,使其可以复用

国旗上色后的代码

\documentclass[varwidth=true]{standalone}
\usepackage[cmyk]{xcolor}
\definecolor{yellow}{cmyk}{0,0,1,0}
\definecolor{red}{cmyk}{0,0.88,0.84,0.07}
\usepackage{tikz}
\newcommand{\xingxing}[3]{
\node[shape=coordinate] (yuanxin#1) at (#3) {};
\draw (yuanxin#1) ++ (#2:1) node[shape=coordinate] (1#1) {};
\draw (yuanxin#1) ++ (#2-72:1) node[shape=coordinate] (2#1) {};
\draw (yuanxin#1) ++ (#2+72:1) node[shape=coordinate] (5#1) {};
\draw (yuanxin#1) ++ (#2+144:1) node[shape=coordinate] (4#1) {};
\draw (yuanxin#1) ++ (#2-144:1) node[shape=coordinate] (3#1) {};
\draw (yuanxin#1) ++ (#2-36:1.15/3) node[shape=coordinate] (-1#1) {};
\draw (yuanxin#1) ++ (#2-108:1.15/3) node[shape=coordinate] (-2#1) {};
\draw (yuanxin#1) ++ (#2+36:1.15/3) node[shape=coordinate] (-5#1) {};
\draw (yuanxin#1) ++ (#2+108:1.15/3) node[shape=coordinate] (-4#1) {};
\draw (yuanxin#1) ++ (#2-180:1.15/3) node[shape=coordinate] (-3#1) {};
\filldraw[fill=yellow,draw=yellow,line width=0pt] (1#1) -- (-1#1) -- (2#1) -- (-2#1) -- (3#1) -- (-3#1) -- (4#1) -- (-4#1) -- (5#1) -- (-5#1) -- (1#1);
}
\newcommand{\xingxingA}[3]{
\node[shape=coordinate] (yuanxin#1) at (#3) {};
\draw (yuanxin#1) ++ (#2:1) node[shape=coordinate] (1#1) {};
\draw (yuanxin#1) ++ (#2-72:1) node[shape=coordinate] (2#1) {};
\draw (yuanxin#1) ++ (#2+72:1) node[shape=coordinate] (5#1) {};
\draw (yuanxin#1) ++ (#2+144:1) node[shape=coordinate] (4#1) {};
\draw (yuanxin#1) ++ (#2-144:1) node[shape=coordinate] (3#1) {};
\draw (yuanxin#1) ++ (#2-36:1.15/3) node[shape=coordinate] (-1#1) {};
\draw (yuanxin#1) ++ (#2-108:1.15/3) node[shape=coordinate] (-2#1) {};
\draw (yuanxin#1) ++ (#2+36:1.15/3) node[shape=coordinate] (-5#1) {};
\draw (yuanxin#1) ++ (#2+108:1.15/3) node[shape=coordinate] (-4#1) {};
\draw (yuanxin#1) ++ (#2-180:1.15/3) node[shape=coordinate] (-3#1) {};
\draw[red,ultra thin] (1#1) -- (-1#1) -- (2#1) -- (-2#1) -- (3#1) -- (-3#1) -- (4#1) -- (-4#1) -- (5#1) -- (-5#1) -- (1#1);
\draw[red,ultra thin] (yuanxin#1) circle [radius=1];
}
\begin{document}
\begin{tikzpicture}[scale=0.25]
\filldraw[fill=red,draw=red,line width=0pt] (0,10) rectangle (30,-10);
\node[shape=coordinate] (yuanxin) at (5,5) {};
\draw (yuanxin) ++ (90:3) node[shape=coordinate] (1) {};
\draw (yuanxin) ++ (90-72:3) node[shape=coordinate] (2) {};
\draw (yuanxin) ++ (90+72:3) node[shape=coordinate] (5) {};
\draw (yuanxin) ++ (90+144:3) node[shape=coordinate] (4) {};
\draw (yuanxin) ++ (90-144:3) node[shape=coordinate] (3) {};
\draw (yuanxin) ++ (90-36:1.15) node[shape=coordinate] (-1) {};
\draw (yuanxin) ++ (90-108:1.15) node[shape=coordinate] (-2) {};
\draw (yuanxin) ++ (90+36:1.15) node[shape=coordinate] (-5) {};
\draw (yuanxin) ++ (90+108:1.15) node[shape=coordinate] (-4) {};
\draw (yuanxin) ++ (90-180:1.15) node[shape=coordinate] (-3) {};
\filldraw[fill=yellow,draw=yellow,line width=0pt] (1) -- (-1) -- (2) -- (-2) -- (3) -- (-3) -- (4) -- (-4) -- (5) -- (-5) -- (1);
%%%%%%%%%%%%%%%%%%%%%%%
\xingxing{1}{180-38.6574}{10,1}
\xingxing{2}{180-15.9454}{12,3}
\xingxing{3}{180+8.1297}{12,6}
\xingxing{4}{180+30.9626}{10,8}
\end{tikzpicture}

\begin{tikzpicture}[scale=0.25]
\draw[red,ultra thin] (0,10) rectangle (15,0);
\draw[red,ultra thin] (15,10) rectangle (30,0);
\draw[red,ultra thin] (0,0) rectangle (15,-10);
\draw[red,ultra thin] (15,0) rectangle (30,-10);
\draw[red,step=1,ultra thin] (0,10) grid (15,0);
\node[shape=coordinate] (yuanxin) at (5,5) {};
\draw (yuanxin) ++ (90:3) node[shape=coordinate] (1) {};
\draw (yuanxin) ++ (90-72:3) node[shape=coordinate] (2) {};
\draw (yuanxin) ++ (90+72:3) node[shape=coordinate] (5) {};
\draw (yuanxin) ++ (90+144:3) node[shape=coordinate] (4) {};
\draw (yuanxin) ++ (90-144:3) node[shape=coordinate] (3) {};
\draw (yuanxin) ++ (90-36:1.15) node[shape=coordinate] (-1) {};
\draw (yuanxin) ++ (90-108:1.15) node[shape=coordinate] (-2) {};
\draw (yuanxin) ++ (90+36:1.15) node[shape=coordinate] (-5) {};
\draw (yuanxin) ++ (90+108:1.15) node[shape=coordinate] (-4) {};
\draw (yuanxin) ++ (90-180:1.15) node[shape=coordinate] (-3) {};
\draw[red,ultra thin] (1) -- (-1) -- (2) -- (-2) -- (3) -- (-3) -- (4) -- (-4) -- (5) -- (-5) -- (1);
\draw[red,ultra thin] (yuanxin) circle [radius=3];
%%%%%%%%%%%%%%%%%%%%%%%
\xingxingA{1}{180-38.6574}{10,1}
\xingxingA{2}{180-15.9454}{12,3}
\xingxingA{3}{180+8.1297}{12,6}
\xingxingA{4}{180+30.9626}{10,8}
\foreach \a in {1,2,3,4} {
\draw[red,ultra thin] (yuanxin) -- (yuanxin\a);
}
\end{tikzpicture}
\end{document}

团旗比较简单,直接放代码

\documentclass{standalone}
\usepackage[cmyk]{xcolor}
\definecolor{yellow}{cmyk}{0,0,1,0}
\definecolor{red}{cmyk}{0,0.88,0.84,0.07}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=red,draw=red,line width=0pt] (0,0) rectangle (36,-24);
\filldraw[even odd rule,fill=yellow,draw=red,line width=0pt]
(9,-6) circle (3)
(9,-6) circle (4);
\path[draw,gray] (9,-6) ++ (90:3) node[shape=coordinate] (a) {};
\path[draw,gray] (9,-6) ++ (162:3) node[shape=coordinate] (b) {};
\path[draw,gray] (9,-6) ++ (234:3) node[shape=coordinate] (c) {};
\path[draw,gray] (9,-6) ++ (306:3) node[shape=coordinate] (d) {};
\path[draw,gray] (9,-6) ++ (18:3) node[shape=coordinate] (e) {};
\path[name path=AC] (a) -- (c);
\path[name path=CE] (c) -- (e);
\path[name path=EB] (e) -- (b);
\path[name path=BD] (b) -- (d);
\path[name path=DA] (d) -- (a);
\path[name intersections={of=AC and EB, by=A1}];
\path[name intersections={of=AC and BD, by=B1}];
\path[name intersections={of=BD and CE, by=C1}];
\path[name intersections={of=DA and CE, by=D1}];
\path[name intersections={of=DA and EB, by=E1}];
\filldraw[fill=yellow,draw=yellow,line width=0pt] (a) -- (A1) -- (b) -- (B1) -- (c) -- (C1) -- (d) -- (D1) -- (e) -- (E1) -- (a);
\end{tikzpicture}
\end{document}

效果图

文章作者: sikouhjw
文章链接: https://sikouhjw.github.io/2021/04/05/2021-04-05-tikz-danghui/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 sikouhjw.github.io
支付宝捐赠
微信捐赠