我绘制了以下图像:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\tikzset{sunbody/.style={line width=1pt,draw=orange,fill=yellow,circle,minimum size=5cm}}
\begin{document}
\begin{tikzpicture}
% draw ground
\fill[brown] (-20,0) -- (-5,10) -- (15,10) -- (8,0) -- cycle;
% draw sun
\draw (13,16) node[sunbody] {};
% draw cloud
\node[cloud, cloud puffs = 10, draw, minimum width = 7cm, minimum height = 4cm, fill = gray!10] at (8,15){};
\end{tikzpicture}
\end{document}
结果是
棕色区域是地球表面。我想尝试让它更逼真。除了云之外,我对大部分绘图都很满意。有人能建议一种让云看起来更逼真的方法吗?这很难用语言表达,但我希望它能覆盖更大面积的天空,就像现实中的云一样,有空隙等。希望这有意义。任何建议都将不胜感激。
答案1
这是一个更加真实的云(以及太阳和地面)的可能实现。
我已经使用了阴影库,请参阅第 66 节 阴影在 TikZ 和 PGF 手册(版本 3.0.0)中。对于云,我只绘制了以相当规则的网格相互重叠的圆圈(参见注释下方的代码% cloud
)。如果您想要其他东西,您可以以更不规则的方式绘制(不完全)重叠的形状,以实现更自然的外观。
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, shadows}
\colorlet{groundcolor}{Black!5!Tan}
\colorlet{darkgroundcolor}{groundcolor!75!Black}
\colorlet{suncolor}{Gold!50!Yellow}
\colorlet{lightsuncolor}{White!5!Gold!35!Yellow}
\colorlet{cloudcolor}{LightGrey!50!Lavender}
\usepackage[active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{0.5cm}
\begin{document}
\begin{tikzpicture}
\tikzstyle{distorted}=[xslant=1.125,%
yscale=0.4]
% ground
\filldraw[groundcolor, distorted] (0, 0) rectangle (10, 10);
\foreach \x in {0.1, 0.2, ..., 9.9} {
\draw[darkgroundcolor,%
very thick,%
decoration={random steps,%
segment length=3pt,%
amplitude=0.5pt},%
decorate,%
distorted] (\x, 0.075) -- (\x, 9.925);
}
% complex sun
\begin{scope}[xshift=13cm, yshift=7cm]
\foreach \x in {0, 30, ..., 350} {
\filldraw[suncolor,%
circular glow={fill=suncolor},%
rotate=\x] (-0.75, 0) parabola (0, 1.35) parabola[bend at end] (0.75, 0) -- cycle;
}
\filldraw[lightsuncolor,%
circular glow={fill=lightsuncolor}] (0, 0) circle[radius=0.75];
\end{scope}
% simple sun
%\filldraw[suncolor,
% circular glow={fill=suncolor}] (13, 7) circle[radius=1];
% cloud
\foreach \x / \y in {10 / 6, 10.5 / 6.5, 11.5 / 6.5, 12 / 6, 11 / 5.75} {
\filldraw[cloudcolor,%
circular glow={fill=cloudcolor}] (\x, \y) circle [radius=0.75];
}
\end{tikzpicture}
\end{document}
答案2
有一点点笨拙,而且随机性并不总是能带来出色的结果,但无论如何......
\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}
\coordinate (sun) at (4,3);
\foreach \i in {0,30,...,330}
\shade [top color=yellow, bottom color=orange, shift=(sun)]
(0,0) -- (\i:4) arc(\i:\i+15:4) -- cycle;
\shade [top color=yellow, bottom color=orange] (sun) circle [radius=2];
\foreach \c in {0,1,2,3,4}{
\shade [shift={(\c*2+rand*2-6,{mod(\c,2)+rnd*3-1})},
top color=cyan, bottom color=blue!50]
(3,0) \foreach \i [evaluate={\k=3-\c*.5; \j=rnd*10; \xr=3+\k/5+rnd/2; \yr=\k+rnd;}] in {1,...,9}{
to [bend right, out=300+\j, in=240-\j] ({\i*20+(rnd*5*\i<9)}:\xr\space and \yr)
};
}
\end{tikzpicture}
\end{document}
答案3
当然,这项工作是用透明像素填充背景。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\tikzset{sunbody/.style={line width=1pt,draw=orange,fill=yellow,circle,minimum size=5cm}}
\begin{document}
\begin{tikzpicture}
% draw ground
\fill[brown] (-20,0) -- (-5,10) -- (15,10) -- (8,0) -- cycle;
% draw sun
\draw (13,16) node[sunbody] {};
% draw cloud
\node[scale=0.5] at (8,15){\pgfkeys{/pgf/images/include external=cloud}};
\end{tikzpicture}
\end{document}