アニメーション

(* ヒトデの定義 *)
starfish=Polygon[
Table[
With[
{r=If[EvenQ[i],0.3,0.8]},
r {Cos[i Pi/5],Sin[i Pi/5]}
],
{i,0,9}
]
];
(* 貝殻の定義 *)
shellPart=FilledCurve[
{
BSplineCurve[
{{0,1},{0.6,0.2},{0.8,-0.4},{0,-0.7},{-0.8,-0.4},{-0.6,0.2},{0,1}},
SplineClosed->True]
}
];

(* アニメーション *)
Animate[
Module[
{starfishPos,shellPos,shell,beachObjects,waveFront,waveMiddle,waveBack,sand,wetSandLine,wetSand,seaShallow,seaMiddle,seaDeep,waveEdge},
(* ヒトデと貝殻 *)
starfishPos={5,1.5};
shellPos={2,1};
shell={
Scale[Rotate[shellPart,Pi],0.45],
Translate[shellPart,{0,-0.6}]
};
beachObjects={
{
RGBColor[0.9,0.4,0.3],
Translate[
Scale[
Rotate[starfish,0.5],
0.6
],
starfishPos
]
},
{
RGBColor[0.98,0.95,0.88],
Translate[
Rotate[
Scale[shell,0.4],
-2 Pi/3
],
shellPos
]
}
};
(* 波の形 *)
waveFront=Table[
{x,4.5-x+3.5 Sin[t]+0.6 Cos[1.5 x-t]+0.2 Sin[4 x+2 t]},
{x,-1,9,0.05}
];
waveMiddle=waveFront/. {x_,y_}->{x,y+0.9};
waveBack=waveFront/. {x_,y_}->{x,y+2.2};
(* 砂浜 *)
sand={
RGBColor[0.94,0.85,0.7],
Rectangle[{0,0},{8,6}]
};
wetSandLine=Table[
{x,4.5-x+2.8 Sin[t-0.5]+0.5 Cos[1.5 x-(t-0.5)]+0.15 Sin[4 x+2 (t-0.5)]-0.8},
{x,-1,9,0.05}
];
wetSand={
RGBColor[0.85,0.75,0.6],
Polygon[
Join[
waveFront,
Reverse[
MapThread[
{#1[[1]],Min[#2[[2]],#1[[2]]-0.05]}&,
{waveFront,wetSandLine}
]
]
]
]
};
(* 海レイヤー *)
seaDeep={
RGBColor[0.15,0.45,0.65],
Polygon[
Join[
{{0,6},{8,6}},
Reverse[waveBack],
{{0,waveBack[[1,2]]}}
]
]
};
seaMiddle={
RGBColor[0.25,0.55,0.75],
Polygon[
Join[
waveBack,
Reverse[waveMiddle]
]
]
};
seaShallow={
RGBColor[0.4,0.75,0.8],
Polygon[
Join[
waveMiddle,
Reverse[waveFront]
]
]
};
(* 波の縁 *)
waveEdge={
AbsoluteThickness[5],
RGBColor[0.95,0.98,1],
Line[waveFront]
};
(* 描画 *)
Graphics[
{sand,wetSand,beachObjects,seaDeep,seaMiddle,seaShallow,waveEdge},
PlotRange->{{0,8},{0,6}},
ImageSize->{640,480},
Axes->False
]
],
(* tの範囲 *)
{t,0,2 Pi},
(* アニメーション速度 *)
AnimationRate->0.25,
(* リフレッシュレート *)
RefreshRate->30
]