Perl generates SVG XML file

Source: Internet
Author: User

Use SVG;

# New SVG

My $svg = Svg->new (
width = 4000,
Height = 5000,
);

# text object, the key is the font type, at first only with ' font ' = ' Arial ', the Web page display font does not look Arial, do not know why. In short, set to ' font-family ', just fine.

Text $svg-
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;

# above are all common object in SVG display, if needed, view http://search.cpan.org/~ronan/SVG-2.28/SVG/Manual.pm

The #每个object size and position can be adjusted to suit your needs.

Perl generates SVG XML file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.