我想绘制一个蛋形格式的元素,但我只找到了绘制椭圆的方法。
答案1
这是使用的唯一解决方案完美的(!) 鸡蛋的参数方程(参见蛋形曲线方程):
- X=H× 0.78 × 余弦(吨× 0.25) × 正弦(吨)
- 是=H× 余弦(吨)
(在哪里H是鸡蛋的高度,吨位于[-π,π])
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\eggheight{3cm}
\path[ball color=orange!60!gray]
plot[domain=-pi:pi,samples=100]
({.78*\eggheight *cos(\x/4 r)*sin(\x r)},{-\eggheight*(cos(\x r))})
-- cycle;
\end{tikzpicture}
\end{document}
编辑:第二个版本色彩更佳。
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\eggheight{3cm}
\path[preaction={fill=orange!50!white},
ball color=orange!60!gray,fill opacity=.5]
plot[domain=-pi:pi,samples=100]
({.78*\eggheight *cos(\x/4 r)*sin(\x r)},{-\eggheight*(cos(\x r))})
-- cycle;
\end{tikzpicture}
\end{document}
答案2
和球阴影结构to[in=angle,out=angle]
对此很有帮助:
代码
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[looseness=0.75,ball color=orange!70!gray] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
\end{tikzpicture}
\end{document}
结果
编辑1:我觉得这个布丁太夸张了。
代码
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[looseness=0.9,ball color=orange!70!gray!50,draw=none] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
\end{tikzpicture}
\end{document}
结果
编辑2:下列的敲击的想法,我加了几个雀斑:
代码
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\colorlet{myEgg}{orange!70!gray!50}
\draw[looseness=0.9,ball color=orange!70!gray!50,draw=none,clip] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
%\fill[blue] (-3,-3) rectangle (3,3);
\foreach \x in {1,...,100}
{ \pgfmathsetmacro{\rDot}{random()/50}
\pgfmathsetmacro{\xCoo}{rand*2}
\pgfmathsetmacro{\yCoo}{rand*2.5+0.5}
\pgfmathsetmacro{\dColor}{100-60*sqrt(pow(\xCoo+0.5,2)+pow(\yCoo-1.4,2))/2.6}
\fill[myEgg!\dColor!black] (\xCoo,\yCoo) circle (\rDot);
}
\end{tikzpicture}
\end{document}
结果
编辑3:特殊要求ガベージコレクタ:这里有 512 只蛙卵(浸在水中):
代码
\documentclass[tikz,border=5mm]{standalone}
\usepackage{xifthen}
\usepackage{fp}
\newcommand{\frogegg}[2]%
{ \draw[ball color=black!80] (#1) circle (#2*0.25cm);
\draw[ball color=cyan!5!gray,opacity=0.1] (#1) circle (#2*1cm);
}
\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}
\begin{document}
\begin{tikzpicture}
[ x={(-27:1cm)},
y={(203:1cm)},
z={(95:1cm)},
]
\foreach \x in {0,...,7}
{ \foreach \y in {0,...,7}
{ \foreach \z in {0,...,7}
{ \pgfmathsetmacro{\xco}{\x+rand/3}
\pgfmathsetmacro{\yco}{\y+rand/3}
\pgfmathsetmacro{\zco}{\z+rand/3}
\pgfmathsetmacro{\rad}{1+rand/3}
\frogegg{\xco,\yco,\zco}{\rad}
}
}
}
\begin{pgfonlayer}{background layer}
\fill[blue!50!gray] (current bounding box.south west) rectangle (current bounding box.north east);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
结果
答案3
快速修复 egreg 的 egg。感谢 MATLAB 运行如此缓慢。
我尝试寻找灰尘遮罩,但找不到能产生更逼真效果的东西。此外,阴影着色有点偏离,但原始渲染也不正确。
\documentclass[tikz]{standalone}
\usetikzlibrary{shadings}
\definecolor{eggshell}{RGB}{252,230,201}
\pgfdeclareradialshading{eggshading}{\pgfpoint{1cm}{1cm}}%
{color(0cm)=(eggshell!80);
color(0.5cm)=(brown!75!eggshell);
color(0.7cm)=(brown);
color(0.9cm)=(brown!70!black);
color(1.2cm)=(black)
}
\pgfdeclareradialshading{eggshadow}{\pgfpointorigin}%
{color(0cm)=(black);
color(2mm)=(gray!80);
color(3mm)=(gray!40);
%color(0.3cm)=(black!5!white);
color(7mm)=(white)
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[yscale=0.93,transform shape]
\node[xscale=2,yscale=0.3,shading=eggshadow,circle,minimum size=7mm] at (0,2.75mm){};
\shade[shading=eggshading] (0,2.7mm)..controls (9mm,0.25cm) and (7mm,2cm)%
..(0,20.5mm)..controls(-7mm,2cm) and (-9mm,2.5mm)..(0,2.7mm)--cycle;
\end{scope}
\node[anchor=south] at (2,0) {\includegraphics[height=2cm]{brownegg}};
\end{tikzpicture}
\end{document}
答案4
用 PSTricks 弄碎的鸡蛋。
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(4.5,4.5)
\pscircle*[linecolor=orange](2,2){1}
\psccurve(0.5,0.5)(0.25,2)(1,3)(2,4)(4,4)(4.5,3)(4,1)(0.8,0.2)(0.5,0.5)
\end{pspicture}
\end{document}
动画版:
在煎锅上……
\documentclass[pstricks]{standalone}
\usepackage{pst-node,pst-plot}
\begin{document}
\pstVerb{realtime srand}%
\psLoop{25}{%
\begin{pspicture}(-2,-2)(2,2)
\pscircle*[linecolor=orange]{0.75}
\curvepnodes[plotpoints=73]{0}{360}{rand 101 mod 1000 div 1.50 add t PtoC}{P}
\def\points{}%
\multido{\i=0+1}{\Pnodecount}{\xdef\points{\points (P\i)}}
\expandafter\psccurve\points
\end{pspicture}}
\end{document}