標籤:
use SVG;
# new SVG
my $svg = SVG->new(
width => 4000,
height => 5000,
);
# text object , 關鍵是字型類型,起先只用 ‘font’ => ‘Arial‘,網頁顯示的字型看起來不是Arial,不知道為啥呢。總之設定成‘font-family’,就好了。
$svg -> text(
id =>‘txttitle‘,
x => 100,
y => 50,
style => {‘font-family‘=>‘Arial, Helvetica, sans-serif‘, ‘font-size‘=>40}
)->cdata($txt_header);
# line object
$svg->line(
id=>"line".$m,
x1=>$border, y1=>$abs_high+($tmprow+1)*($border+$image_high)+30,
x2=>$ncol*($border+$image_width), y2=>$abs_high+($tmprow+1)*($border+$image_high)+30,
style=>{‘stroke-width‘=>‘2.5‘,‘stroke‘=>‘black‘}
);
# image object
$svg->image(
x=>($tmpcol+1)*$border+$tmpcol*$image_width+40, y=>$abs_high+($tmprow+1)*$border+$tmprow*$image_high,
width=>$image_width, height=>$image_high,
‘-href‘=>"$txt_header/$plt_name[$m].jpg", #may also embed SVG, e.g. "image.svg"
id=> "image$m"
);
# output svg object as xml format
open(OUT,">$txt_header.svg") || die;
print OUT $svg->xmlify;
close OUT;
# 以上都是在SVG 顯示中常見的object,如果需要其他的,查看 http://search.cpan.org/~ronan/SVG-2.28/SVG/Manual.pm
#每個object 大小和位置可根據需要,自行調整。
perl 產生SVG 的xml 檔案