

具象的な曲線の4回目はエッグカーブです。
参考サイトには様々なエッグカーブの数式やハート、りんご形曲線などが紹介されています。
x=a*cos(th)
y=(b+c*cos(th))*sin(th)
TDCC LABORATORY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 %!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 240 240
%%Title:egg curve(エッグカーブ)を描く
0 0 240 240 rectfill % 黒背景
120 120 translate % 図形を中央に移動
/a 100 def % 図の左右の長さ
/b 70 def % 図の天地の長さ
/c 10 def % 丸み
newpath % パスの初期化
0 1 360 { % 0から始めて360まで1づつ増分し{ }内を繰り返す
/th exch def % 制御変数をth(角度)に入れる
% エッグカーブの数式
/x a th cos mul def
/y b c th cos mul add th sin mul def
% thが0なら始点を置き、さもなくば線を引く
th 0 eq { x y moveto } { x y lineto } ifelse
} for
closepath % 線を繋ぐ
1 1 1 setrgbcolor % 白色
2 setlinewidth % 線幅2ポイント
stroke % 線を描画

卵を小さくしていきます。
今回はa、b、cのパラメータの比率を保ったまま縮小したいのでscaleを使います。
また下に移動させて変化をつけています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 %!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 240 240
%%Title:egg curve(エッグカーブ)を描く
0 0 240 240 rectfill % 黒背景
120 120 translate % 図形を中央に移動
/a 100 def % 図の左右の長さ
/b 70 def % 図の天地の長さ
/c 10 def % 丸み
/rc 0 def % R色
/gc 0 def % G色
/bc .95 def % B色
newpath % パスの初期化
80 { % 80回{ }内を繰り返す
0 1 360 { % 0から始めて360まで1づつ増分し{ }内を繰り返す
/th exch def % 制御変数をth(角度)に入れる
% エッグカーブの数式
/x a th cos mul def
/y b c th cos mul add th sin mul def
% thが0なら始点を置き、さもなくば線を引く
th 0 eq { x y moveto } { x y lineto } ifelse
} for
closepath % 線を繋ぐ
rc gc bc setrgbcolor % カラー設定
fill % 塗りつぶす
/rc rc .03 add def % R色から0.03を足す
/gc gc .01 add def % G色から0.01を足す
/bc bc .01 sub def % B色から0.01を引く
.97 dup scale % 座標を0.97倍
0 -1 translate % 座標を-1下に移動
} repeat
コメント