-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawer.pl
60 lines (50 loc) · 2.1 KB
/
drawer.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use strict;
use List::Util qw (reduce);
use SVG;
use CFDGParser;
use Grammar;
my $svg = SVG->new(width=>600, height=>400);
open INPUT, $ARGV[0] or die $!;
open OUTPUT, '>', $ARGV[1] or die $!;
my @lines = <INPUT>;
my $text = reduce { $a.$b } "", grep { $_ !~ /\/\//} @lines;
my $parsed = CFDGParser::parse($text);
my $drawing = Grammar->new($parsed);
$drawing->to_svg($svg, 50);
#~ ===================== P A R S E R T E S T =========================
#~ ====================================================================
#~ ===================== S V G T E S T ==============================
#~ my $ano=$svg->tag('g',
#~ #id => 'group_ano',
#~ style => {
#~ stroke => 'rgb(100,200,50)',
#~ fill => 'rgb(10,150,100)'
#~ }
#~ );
#~ $ano->tag('circle', cx=>50, cy=>50, r=>100, id=>'circle_in_group_ano');
#~ my $z=$svg->tag('g',
#~ #id => 'group_z',
#~ style => {
#~ stroke => 'rgb(100,200,50)',
#~ fill => 'rgb(120,100,25)'
#~ },
#~ transform=>'translate(100, 150)',
#~ );
#~ # create and add a circle using the generic 'tag' method
#~ $z->tag('circle', cx=>50, cy=>50, r=>100);#, id=>'circle_in_group_z');
#~ $z->tag('rect', width=>120, height=>50, # id=>'rect_in_group_z',
#~ transform=>'scale(1.5), rotate(-45), translate(30, 0), translate(0, -20)');
#~ # create an anchor on a rectangle within a group within the group z
#~ my $k = $z->anchor(
#~ id => 'anchor_k',
#~ -href => 'http://google.bg/',
#~ target => 'new_window_0'
#~ )->rectangle(
#~ x => 20, y => 50,
#~ width => 20, height => 30,
#~ rx => 10, ry => 5,
#~ #id => 'rect_k_in_anchor_k_in_group_z',
#~ transform=>'skewX(30)'
#~ );
# now render the SVG object, implicitly use svg namespace
print OUTPUT $svg->xmlify;