#!/usr/local/bin/perl # $Id: image-2.cgi,v 1.4 2004/07/21 17:42:09 68user Exp $ use strict; use GD; my $PI = 3.141592; my $width = 500; # 画像の幅 my $height = 200; # 画像の高さ my $im = new GD::Image($width, $height); my $black = $im->colorAllocate( 0, 0, 0); my $str_color = $im->colorAllocate( 0, 0, 0); my $str_shadow_color = $im->colorAllocate(190, 190, 190); my $bgcolor = $im->colorAllocate(255, 255, 255); my $circle_color = $im->colorAllocate(230, 110, 110); # インタレースを ON $im->interlaced('true'); # 背景色として塗りつぶし四角を描く $im->filledRectangle(0, 0, $width-1, $height-1, $bgcolor); # 外枠を描画 $im->rectangle(0, 0, $width-1, $height-1, $black); # 内側の丸を書いて、外側の丸を書いて、内側と外側の丸の間を塗りつぶす $im->arc($width/2, $height/2, 160, 160, 0, 360, $circle_color); $im->arc($width/2, $height/2, 220, 220, 0, 360, $circle_color); $im->fill($width/2+81, $height/2, $circle_color); my $fontsize_min = 10; # 初期フォントサイズ my $fontsize_max = 50; # 最大フォントサイズ my $fontsize_delta = 7; # フォントサイズ増分 my $str_x = 0; # X 座標 my $str_y = $fontsize_min; # Y 座標 my $angle = 0; # 回転角度 (ラジアン) my $font_file ='/usr/X11R6/lib/X11/fonts/TrueType/sazanami-gothic.ttf'; my @strs = ('寿限無寿限無五劫のすりきれ海砂利水魚の水行末雲来末風来末食う寝るところに住むところやぶら小路のぶら小路', '祇園精舎の鐘の声 諸行無常の響きあり 沙羅双樹の花の色 盛者必衰の理をあらわす おごれる人も久しからず', '春はあけぼの。やうやう白くなりゆく山ぎは、少し明りて、紫だちたる雲の、細くたなびきたる。夏は、夜。', '色は匂へど 散りぬるを 我がよ誰そ 常ならむ 有為の奥山 今日越えて あさき夢見し ゑひもせず', ); my $str = $strs[int(rand(scalar(@strs)))]; for ( my $size=$fontsize_min ; $size<=$fontsize_max ; $size += $fontsize_delta ){ # 文字の影を描画 $im->stringFT($str_shadow_color, # 色 $font_file, $size, # フォント・フォントサイズ $angle*($PI/180), # 回転角度 $str_x+2, $str_y+2, # X・Y 座標 $str); # 表示文字列 # 文字を描画 $im->stringFT($str_color, # 色 $font_file, $size, # フォント・フォントサイズ $angle*($PI/180), # 回転角度 $str_x, $str_y, # X・Y 座標 $str); # 表示文字列 $str_y += $size+14; $angle -= 2; } binmode STDOUT; print "Content-type: image/png\n\n"; print $im->png; exit 0;