PerlのGDモジュールで円状に配置する方法
#!/usr/local/bin/perl use GD; $p = 3.1415926535; # パイを表現 $rad = 360 / (2 * $p); # ラジアンを表現 @circles = ("Obj-1", "Obj-2", "Obj-3", "Obj-4", "Obj-5"); $im = new GD::Image(500,400); #PNGファイルの大きさを設定 #色の定義 $white = $im->colorAllocate(255,255,255); $black = $im->colorAllocate(0,0,0); $blue = $im->colorAllocate(0,0,255); $red = $im->colorAllocate(255,0,0); $im->transparent($white); $im->interlaced('true'); $im->rectangle(0,0,499,399,$black); $radius = 150; #円の半径を設定 $center = 200; #円の中心位置を設定 $circle_num = @circles; #円状に配置するオブジェクトの数 for($i=1;$i<=@circles;$i++){ $sin = sin( ($i * (360 / $circle_num) ) / $rad); $cos = cos( ($i * (360 / $circle_num) ) / $rad); $x = int ".$png_name">*1 { binmode(OUT); print OUT $im->png; close(OUT); chmod(0777, $png_name); }
一部参考:GD.pm - Gdグラフィックス・ライブラリへのインターフェース
これを使って、円状に配置したマークから関連のある別のマークに線を引いたりもできる。というか、そういうプログラムを今日書いたってだけ。またも無断転載。こういう場合の著作権とかってどこにあるんだろう。