码迷,mamicode.com
首页 > 其他好文 > 详细

perl 生成SVG 的xml 文件

时间:2016-07-07 14:25:15      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

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 文件

标签:

原文地址:http://www.cnblogs.com/Sophie2016-Bio/p/5649927.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!