我如何将这个 [Metapost 源] 翻译成 Tikz?
for i:=0 upto 12:
yy := 50 - (25 / 3 * i);
xx := - sqrt(3600 - yy * yy) - 10;
drawarrow (-100,yy)--(xx,yy) withcolor (1,1,0);
endfor;
fill fullcircle scaled 100 withcolor (1,1,.3);
fill (halfcircle--cycle) rotated -90 scaled 100 withcolor (.3,.2,.1);
draw axe rotated 23;
for i:=1 upto 7:
yy := 50 - i * 12.5;
xx := sqrt(2500 - yy * yy);
draw ((xx,yy)--(-xx,yy)) rotated 23 withpen pencircle scaled .5pt
withcolor .6white;
endfor;
label.urt(btex $N$ etex,(0,50) rotated 23);
label.lrt(btex $S$ etex,(0,-50) rotated 23);
输出结果应该是这样的:
答案1
这是一个想法。它并不完美,因为我不熟悉 MetaPost 语法。但我认为这是一个很好的起点。如果有人看到改进此代码的方法,我愿意接受建议。
\documentclass{article}
\usepackage{tikz}
% define your color, same syntax as xcolor package
\definecolor{mysunray}{rgb}{1,1,0}
\definecolor{myday}{rgb}{1,1,0.3}
\definecolor{mynight}{rgb}{0.3,0.2,0.1}
\begin{document}
\begin{tikzpicture}[x=1pt,y=1pt]
% the sun rays
\foreach \x in {0,1,...,12}
{\pgfmathsetmacro{\yy}{50-25/3*\x}
\pgfmathsetmacro{\xx}{-sqrt(3600-\yy*\yy)-10}
\draw[->,>=latex,mysunray,line width=1pt] (-100,\yy) -- (\xx,\yy);}
% earth
\fill[myday] (0,-50) arc (270:90:50) -- cycle;
\fill[mynight] (0,-50) arc (-90:90:50) -- cycle;
% parallels
\foreach \x in {1,2,...,7}
{\pgfmathsetmacro{\yy}{50-\x*12.5}
\pgfmathsetmacro{\xx}{sqrt(2500-\yy*\yy)}
\draw[black!40,line width=0.5pt,rotate=23.43] (-\xx,\yy) -- (\xx,\yy);}
% earth axis and poles
\node (north) at (90+23.43:60) {$N$};
\node (south) at (-90+23.43:60) {$S$};
\draw (north) -- (south);
\end{tikzpicture}
\end{document}
为了定义颜色,我使用rgb
0 到 1 之间的数字的选项。还有一个选项RGB
是采用 0 到 255 之间的整数。
对于平行线的颜色,我使用了black!40
40% 黑色(和 60% 白色)。我不确定它是否与您的相同0.6white
。