
ランダムな色で円を並べて行きます。
17〜22行 RGB各色のランダムな値を設定します。
値を0〜10まで発生させ(rand 11 mod)それに0.1を掛ける(0.1 mul)ことで、0.0~1.0まで0.1刻みの数値を各色に設定します。
28〜32行 画面サイズ(gw,gh)をグリッド数(grid)で割ってグリッド幅(w,h)出しています。
33行 横幅(w)を2で割って円の半径(rad)としています。
43行 closepathは正円の場合は必要ありません。34〜35行で開始角と終了角を変更して弧にする場合に使用します。
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 720 720 %%HiResBoundingBox: 0 0 720 720 %%CropBox: 0 0 720 720 %%Title:円の配置 %%Copyright:Studio Fruit Jam / Toyokazu Nishi %%CreationDate:2018年7月11日 水曜日午後0:29:44 % ================ 座標変換 ================ 0 0 translate % ================ 背景 ================= 0 0 0 setrgbcolor 0 720 720 -720 rectfill % ================================================ % ランダムカラー 0.0~1.0までの乱数発生 % ================================================ /random_color { /rc rand 11 mod 0.1 mul def % R色 /gc rand 11 mod 0.1 mul def % G色 /bc rand 11 mod 0.1 mul def % B色 rc gc bc setrgbcolor % カラー設定 } def % ================================================ % 円の配置 % ================================================ % ====================== 初期値 /gw 720 def % 横幅画面サイズ(変更可) /gh 720 def % 縦幅画面サイズ(変更可) /grid 10 def % グリッド数(変更可) /w gw grid div def % グリッド横幅 /h gh grid div def % グリッド縦幅 /rad w 2 div def % 半径はgrid数で決まる /sa 0 def % 開始角(start angle)(変更可) /ea 360 def % 終了角(end angle)(変更可) % ====================== %circleプロシージャ (変更不可) /circle { /uy exch def % y座標取得 /ux exch def % x座標取得 ux uy translate % x y座標移動 0 0 moveto % 始点 0 0 rad sa ea arc % 円の描画 % closepath % パスを閉じる(弧の場合必要) random_color % ランダムカラープロシージャ呼び出し fill % 塗りつぶし } def % ================================================ % メイン % ================================================ 0 1 grid { % 0〜gridまで繰り返す /hd exch def % 縦のグリッド数を取得 /y h hd mul def % y座標を計算 0 1 grid { % 0〜gridまで繰り返す /wd exch def % 横のグリッド数を取得 /x w wd mul def % x座標を計算 gsave x y circle grestore % circleプロシージャ呼び出し } for } for |
【応用例】

コメント