#!/usr/bin/perl
use strict;
use warnings;
use SVG;
# create an SVG object with a size of 40x40 pixels
my $svg = SVG->new(
width => 40,
height => 40,
);
# add a circle
$svg->circle(
cx => 20,
cy => 20,
r => 15,
style => {
'fill' => 'rgb(255, 0, 0)',
'stroke' => 'blue',
'stroke-width' => 5,
'stroke-opacity' => 1,
'fill-opacity' => 1,
}
);
#my $text1 = $svg->text(
# #id => 'l1',
# x => 10,
# y => 10
#)->cdata('hello, world');
# now render the SVG object, implicitly use svg namespace
#print $svg->xmlify;
my $out = $svg->xmlify;
open SF, ">tmp.svg";
print SF $out;
老师,利用上面的代码创建一个 width => 40,height => 40,的画布,但是怎么设置画布的背景色呢,我看官网上也没有说明!画出来是下面这样的图
老师用SVG比较少,你可以自学svg:http://www.w3school.com.cn/svg/index.asp
如果觉得我的回答对您有用,请随意打赏。你的支持将鼓励我继续创作!