我试图代表我国的国旗。我输入了这段代码。但我认为星星、圆圈等的位置并不那么受尊重。此外,我有一个左边距“白色带”,我想消除它,但没有结果。
请您帮我获取正确的代码。
%A tunisian flag
%Author: Fethi GHARIANI
%using Tom Bombadil code in http://tex.stackexchange.com/questions/58903/how-to-draw-star-in-tikz-background who uses a macro for drawing stars as well as "n-grams"
\documentclass[fontsize=14pt]{scrartcl}
\usepackage[norsk,francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[dvips=false,pdftex=false,vtex=false,paperwidth=24cm,paperheight=16cm,margin=0cm,bottom=0cm,top=0cm,nohead]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
% inner radius, outer radius, tips, rot angle, options étoile
\newcommand{\tstar}[5]{
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}
\newcommand{\ngram}[4]{% outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#2}
\pgfmathsetmacro{\innerradius}{#1*sin(90-\starangle)/sin(90+\starangle/2)}
\tstar{\innerradius}{#1}{#2}{#3}{#4}
}
\definecolor{rec}{rgb}{1,0,0}
\definecolor{cir}{rgb}{1,1,1}
\definecolor{hon}{rgb}{1,0,0}
\definecolor{sta}{rgb}{1,1,1}
\begin{document}
\begin{tikzpicture}
\fill[rec] rectangle (24cm,16cm);
\fill[cir] (12,8) circle (4cm);
\fill[hon] (12,8) circle (3cm);
\fill[sta] (12.8,8) circle (2.4cm);
\ngram{1.5}{5}{72}{red,thick,fill=red,xshift=13.2cm,yshift=8cm};
\end{tikzpicture}
\end{document}
答案1
不需要 n-grams 代码。标准star
节点形状即可。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\definecolor{red}{RGB}{206,17,38}
\noindent\begin{tikzpicture}
% Use wikipedia's dimensions
\fill[red] rectangle (12, 8);
\fill[white] (6,4) circle (2);
\fill[red] (6,4) circle (1.5);
\fill[white] (6.4,4) circle (1.2);
\node[star,fill=red, minimum size=1.8cm, rotate=90, star point ratio=2.617,inner sep=0pt] at (6.4,4) {};
% Star point ratio is GoldenRatio^2 (1.618^2)
\end{tikzpicture}
\end{document}
尺寸取自1999年法律之后的规范。该规范没有提及星形和旋转,但可以安全地假设它是一个正五角星,并且旗帜具有水平对称轴,这完成了所需的信息。
更新
有1999年之前版本:
在这种情况下,我编写了一个更复杂的代码,以展示不同的技术。标志中的所有元素都是 tikz 节点,样式定义它们的大小和位置。此外,所有尺寸都是相对的,\flagwidth
可以随意更改。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes.geometric}
\definecolor{red}{RGB}{206,17,38}
\def\flagwidth{6cm}
\tikzset{
flag/.style = {
fill=red,
minimum width=\flagwidth,
minimum height=2/3*\flagwidth,
inner sep = 0pt,
},
inner circle/.style = {
fill = white,
minimum size=1/3*\flagwidth,
circle,
inner sep = 0pt,
},
crescent/.style = {
fill = red,
minimum size = 2/9*\flagwidth,
circle,
inner sep = 0pt,
after node path = {node[moon] {}},
},
moon/.style = {
fill = white,
xshift= 1/45*\flagwidth,
minimum size = 1/5*\flagwidth,
inner sep = 0pt,
circle,
},
inner star/.style = {
fill = red,
star,
inner sep = 0pt,
xshift= 1/30*\flagwidth,
minimum size=4/27*\flagwidth,
rotate=90,
star point ratio=2.617,
}
}
\noindent\begin{tikzpicture}%[scale=0.01]
% Use pre 1999 dimensions
% http://en.wikipedia.org/wiki/File:Mesures_drapeau_Tunisie_avant_1999.svg
\draw node[flag] {}
node[inner circle] {}
node[crescent] {}
node[inner star] {};
\end{tikzpicture}
\end{document}
答案2
这是土耳其国旗:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\definecolor{red}{RGB}{227, 10, 23}
\noindent\begin{tikzpicture}
% Use wikipedia's dimensions
\fill[red] rectangle (12, 8);%G=8, L=12, L=1.5 G
\fill[white] (4,4) circle (2);
\fill[red] (4.5,4) circle (1.6);
\node[star,fill=white, minimum size=2cm, rotate=90, star point ratio=2.617,inner sep=0pt] at (6.83333333333,4) {};
\end{tikzpicture}
\end{document}
答案3
根据其制作图纸绘制的突尼斯国旗和土耳其国旗l3draw
(请注意,半月形不是简单地将两个圆圈相互拼接起来构成的,而是通过计算角度和绘制两个圆弧的坐标构成的):
\documentclass[border=10pt, multi=draw]{standalone}
\usepackage{l3draw}
\ExplSyntaxOn
\cs_new:Npn \myflags_draw_five_pointed_star:nnn #1 #2 #3 {
\draw_scope_begin:
\draw_transform_shift:n { #1 }
\draw_path_moveto:n { \draw_point_polar:nn { #2 } { #3 } }
\int_step_inline:nnnn { 72 } { 72 } { 360 } {
\draw_path_lineto:n
{ \draw_point_polar:nn { 2 / ( 3 + sqrt(5) ) * #2 } { #3 + ##1 - 36 } }
\int_compare:nNnF { ##1 } = { 360 } {
\draw_path_lineto:n { \draw_point_polar:nn { #2 } { #3 + ##1 } }
}
}
\draw_path_close:
\draw_path_use_clear:n { fill }
\draw_scope_end:
}
\cs_generate_variant:Nn \clist_item:nn { en }
\tl_new:N \l_myflags__intersect_circles_tl
\fp_new:N \l_myflags_crescent_outer_angle_fp
\fp_new:N \l_myflags_crescent_inner_angle_fp
\cs_new:Npn \myflags_draw_crescent:nnnn #1 #2 #3 #4 {
\tl_set:Nn \l_myflags_crescent_intersect_circles_tl {
\draw_point_intersect_circles:nnnnn { #1 } { #2 } { #3 } { #4 } { 2 }
}
\fp_set:Nn \l_myflags_crescent_outer_angle_fp {
atand (
\clist_item:en { \l_myflags_crescent_intersect_circles_tl } { 2 } -
\clist_item:en { \draw_point:n { #1 } } { 2 } ,
\clist_item:en { \l_myflags_crescent_intersect_circles_tl } { 1 } -
\clist_item:en { \draw_point:n { #1 } } { 1 }
)
}
\fp_set:Nn \l_myflags_crescent_inner_angle_fp {
atand (
\clist_item:en { \l_myflags_crescent_intersect_circles_tl } { 2 } -
\clist_item:en { \draw_point:n { #3 } } { 2 } ,
\clist_item:en { \l_myflags_crescent_intersect_circles_tl } { 1 } -
\clist_item:en { \draw_point:n { #3 } } { 1 }
)
}
\draw_path_moveto:n { \l_myflags_crescent_intersect_circles_tl }
\draw_path_arc:nnn { \l_myflags_crescent_outer_angle_fp }
{ 360 - \l_myflags_crescent_outer_angle_fp } { #2 }
\draw_path_arc:nnn { 360 - \l_myflags_crescent_inner_angle_fp }
{ \l_myflags_crescent_inner_angle_fp } { #4 }
\draw_path_close:
}
\NewDocumentEnvironment{draw}{ }{
\ExplSyntaxOn
\draw_begin:
}{
\draw_end:
\ExplSyntaxOff
}
\ExplSyntaxOff
\begin{document}
\begin{draw}
\color_fill:nn { RGB } { 206 , 17 , 38 }
\draw_path_rectangle_corners:nn { 0cm , 0cm } { 12cm , 8cm }
\draw_path_use_clear:n { fill }
\color_fill:n { white }
\draw_path_circle:nn { 6cm , 4cm } { 2cm }
\draw_path_use_clear:n { fill }
\color_fill:nn { RGB } { 206 , 17 , 38 }
\myflags_draw_crescent:nnnn { 6cm , 4cm } { 1.5cm } { 6.4cm , 4cm } { 1.2cm }
\draw_path_use_clear:n { fill }
\color_fill:nn { RGB } { 206 , 17 , 38 }
\myflags_draw_five_pointed_star:nnn { 6.4cm , 4cm } { 0.9cm } { 180 }
\draw_path_use_clear:n { fill }
\end{draw}
\begin{draw}
\color_fill:nn { RGB } { 227 , 10 , 23 }
\draw_path_rectangle_corners:nn { 0cm , 0cm } { 12cm , 8cm }
\draw_path_use_clear:n { fill }
\color_fill:n { white }
\myflags_draw_crescent:nnnn { 4cm , 4cm } { 2cm } { 4.5cm , 4cm } { 1.6cm }
\draw_path_use_clear:n { fill }
\myflags_draw_five_pointed_star:nnn { 6.4cm , 4cm } { 1cm } { 180 }
\draw_path_use_clear:n { fill }
\end{draw}
\end{document}