

randを使って位置、長さ、線幅をランダムな値にして直線を描きます。
位置を枠の範囲内になるよう-100から100の間に設定します。
1 2 3 4 5 6 7 8 9 10 11 12 | %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 240 240 %%Title:ランダムにラインパターンを描く newpath % パスの初期化 0 1 200 { % 0から1づつ増やし200になるまで{ }内を繰り返す /x rand 201 mod 100 sub def % x座標(-100〜100) /y rand 201 mod 100 sub def % y座標(-100〜100) /w rand 151 mod 70 sub def % 横幅(-70〜80) /h rand 151 mod 70 sub def % 縦幅(-70〜80) rand 11 mod .1 mul setlinewidth % 線幅(0.0〜1.0) x y moveto w h rlineto stroke % (x,y)を始点として(w,h)相対座標で直線を描く } for |

カラーをランダムに設定します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 240 240 %%Title:ランダムにラインパターンを描く /randam_color { ランダムカラープロシージャ /r rand 11 mod 0.1 mul def % R色(0.1〜1) /g rand 5 mod 0.1 mul def % G色(0.1〜0.4) /b rand 11 mod 0.1 mul def % B色(0.1〜1) r g b setrgbcolor RGBカラー設定 } def 120 120 translate % 座標の原点を中央に移動 newpath % パスの初期化 0 1 200 { % 0から1づつ増やし200になるまで{ }内を繰り返す /x rand 201 mod 100 sub def % x座標(-100〜100) /y rand 201 mod 100 sub def % y座標(-100〜100) /w rand 151 mod 70 sub def % 横幅(-70〜80) /h rand 151 mod 70 sub def % 縦幅(-70〜80) rand 5 mod 1 add setlinewidth % 線幅(1〜5) randam_color % プロシージャ呼び出し x y moveto w h rlineto stroke (x,y)を始点として(w,h)相対座標で直線を描く } for |
コメント