line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FigAnim; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23276
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# useful classes |
9
|
1
|
|
|
1
|
|
533
|
use FigAnim::Color; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
10
|
1
|
|
|
1
|
|
525
|
use FigAnim::Arc; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
723
|
use FigAnim::Compound; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
12
|
1
|
|
|
1
|
|
597
|
use FigAnim::Ellipse; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
13
|
1
|
|
|
1
|
|
676
|
use FigAnim::Polyline; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
14
|
1
|
|
|
1
|
|
725
|
use FigAnim::Spline; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
15
|
1
|
|
|
1
|
|
583
|
use FigAnim::Text; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
24
|
|
16
|
1
|
|
|
1
|
|
4
|
use FigAnim::Utils; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
17
|
1
|
|
|
1
|
|
557
|
use FigAnim::ConvertSVG; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
18
|
1
|
|
|
1
|
|
550
|
use FigAnim::ConvertSMIL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
19
|
1
|
|
|
|
|
21767
|
use Math::Trig qw(deg2rad |
20
|
|
|
|
|
|
|
cartesian_to_cylindrical |
21
|
1
|
|
|
1
|
|
2374
|
cylindrical_to_cartesian); |
|
1
|
|
|
|
|
31581
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# constructor |
24
|
|
|
|
|
|
|
sub new { |
25
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
26
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
27
|
0
|
|
|
|
|
|
my $self = {}; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{title} = ""; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# header |
32
|
0
|
|
|
|
|
|
$self->{version} = undef; |
33
|
0
|
|
|
|
|
|
$self->{orientation} = undef; |
34
|
0
|
|
|
|
|
|
$self->{justification} = undef; |
35
|
0
|
|
|
|
|
|
$self->{units} = undef; |
36
|
0
|
|
|
|
|
|
$self->{papersize} = undef; |
37
|
0
|
|
|
|
|
|
$self->{magnification} = undef; |
38
|
0
|
|
|
|
|
|
$self->{multiple_page} = undef; |
39
|
0
|
|
|
|
|
|
$self->{transparent_color} = undef; |
40
|
0
|
|
|
|
|
|
$self->{resolution} = undef; |
41
|
0
|
|
|
|
|
|
$self->{coord_system} = undef; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# array containing the Color objects |
44
|
0
|
|
|
|
|
|
$self->{colors} = []; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# arrays containing every object's name classified by type |
47
|
0
|
|
|
|
|
|
$self->{arcs} = []; |
48
|
0
|
|
|
|
|
|
$self->{compounds} = []; |
49
|
0
|
|
|
|
|
|
$self->{ellipses} = []; |
50
|
0
|
|
|
|
|
|
$self->{polylines} = []; |
51
|
0
|
|
|
|
|
|
$self->{splines} = []; |
52
|
0
|
|
|
|
|
|
$self->{texts} = []; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# hash containing all the objects (except Color objects) |
55
|
|
|
|
|
|
|
# with their names as keys |
56
|
0
|
|
|
|
|
|
$self->{objects} = {}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# number of the current unnamed object |
59
|
0
|
|
|
|
|
|
$self->{num} = 1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# array containing all the animations |
62
|
0
|
|
|
|
|
|
$self->{animations} = []; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
bless ($self, $class); |
65
|
0
|
|
|
|
|
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# methods |
70
|
|
|
|
|
|
|
sub clone { |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my $obj = new FigAnim; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
foreach ('title','version','orientation','justification','units', |
75
|
|
|
|
|
|
|
'papersize','magnification','multiple_page','transparent_color', |
76
|
|
|
|
|
|
|
'resolution','coord_system','arcs','compounds','ellipses', |
77
|
|
|
|
|
|
|
'polylines','splines','texts') { |
78
|
0
|
|
|
|
|
|
$obj->{$_} = $self->{$_}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
foreach (@{$self->{colors}}) { |
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
push @{$obj->{colors}}, $_->clone(); |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
foreach (keys %{$self->{objects}}) { |
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$obj->{objects}->{$_} = $self->{objects}->{$_}->clone(); |
87
|
0
|
|
|
|
|
|
$obj->{objects}->{$_}->{fig_file} = $obj; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $obj; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# parser |
95
|
|
|
|
|
|
|
sub parseFile { |
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
97
|
0
|
|
|
|
|
|
my $filename = shift; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
open IN, "<$filename" or die "Can't open $filename : $!\n"; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$self->parseHeader(\*IN); |
102
|
0
|
|
|
|
|
|
$self->parseObjects(\*IN,$self); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
close IN; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub parseHeader { |
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
109
|
0
|
|
|
|
|
|
my $fh = shift; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $line = <$fh>; |
112
|
0
|
0
|
|
|
|
|
return unless ($line =~ /^\#FIG (\d(.\d)*)\n$/); |
113
|
0
|
|
|
|
|
|
$self->{version} = $1; |
114
|
0
|
|
|
|
|
|
$self->{orientation} = nextline($fh); |
115
|
0
|
|
|
|
|
|
$self->{justification} = nextline($fh); |
116
|
0
|
|
|
|
|
|
$self->{units} = nextline($fh); |
117
|
0
|
|
|
|
|
|
$self->{papersize} = nextline($fh); |
118
|
0
|
|
|
|
|
|
$self->{magnification} = nextline($fh); |
119
|
0
|
|
|
|
|
|
$self->{multiple_page} = nextline($fh); |
120
|
0
|
|
|
|
|
|
$self->{transparent_color} = nextline($fh); |
121
|
0
|
|
|
|
|
|
while (($line = nextline($fh)) =~ /^\# /) { |
122
|
0
|
|
|
|
|
|
$line =~ s/\# //; |
123
|
0
|
|
|
|
|
|
$self->{title} .= $line . "\n"; |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
($self->{resolution}, $self->{coord_system}) = split / /, $line; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub parseObjects { |
129
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
130
|
0
|
|
|
|
|
|
my $fh = shift; |
131
|
0
|
|
|
|
|
|
my $current = shift; |
132
|
0
|
|
|
|
|
|
my ($line, $object_code, $object, @attr); |
133
|
0
|
|
|
|
|
|
my $name = ""; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
while ($line = nextline($fh)) { |
136
|
0
|
0
|
|
|
|
|
return if ($line =~ /^-6/); |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
@attr = split / /, $line; |
139
|
0
|
|
|
|
|
|
$object_code = shift @attr; |
140
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
if ($object_code eq "0") { # Color |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$object = new Color(@attr); |
143
|
0
|
|
|
|
|
|
push @{$self->{colors}}, $object; |
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
elsif ($object_code eq "#") { # Comment |
147
|
0
|
|
|
|
|
|
$line =~ s/^\# //; |
148
|
0
|
|
|
|
|
|
$name .= $line . "\n"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
elsif ($object_code eq "5") { # Arc |
152
|
0
|
0
|
|
|
|
|
if ($attr[11]) { # forward_arrow == 1 |
153
|
0
|
|
|
|
|
|
$line = nextline($fh); |
154
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
155
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
156
|
|
|
|
|
|
|
} else { |
157
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
if ($attr[12]) { # backward_arrow == 1 |
161
|
0
|
|
|
|
|
|
$line = nextline($fh); |
162
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
163
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
164
|
|
|
|
|
|
|
} else { |
165
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
169
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
170
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
171
|
|
|
|
|
|
|
} |
172
|
0
|
|
|
|
|
|
$object = new Arc($name,@attr,$self); |
173
|
0
|
|
|
|
|
|
push @{$current->{arcs}}, $name; |
|
0
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
175
|
0
|
|
|
|
|
|
$name = ""; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
elsif ($object_code eq "6") { # Compound |
179
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
180
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
181
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
182
|
|
|
|
|
|
|
} |
183
|
0
|
|
|
|
|
|
$object = new Compound($name,@attr,$self); |
184
|
0
|
|
|
|
|
|
$object->calculateCenter(); |
185
|
0
|
|
|
|
|
|
push @{$current->{compounds}}, $name; |
|
0
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
187
|
0
|
|
|
|
|
|
$name = ""; |
188
|
0
|
|
|
|
|
|
$self->parseObjects(\*IN,$object); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
elsif ($object_code eq "1") { # Ellipse |
192
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
193
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
194
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
195
|
|
|
|
|
|
|
} |
196
|
0
|
|
|
|
|
|
$object = new Ellipse($name,@attr,$self); |
197
|
0
|
|
|
|
|
|
push @{$current->{ellipses}}, $name; |
|
0
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
199
|
0
|
|
|
|
|
|
$name = ""; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
elsif ($object_code eq "2") { # Polyline |
203
|
0
|
0
|
|
|
|
|
if ($attr[12]) { # forward_arrow == 1 |
204
|
0
|
|
|
|
|
|
$line = nextline($fh); |
205
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
206
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
207
|
|
|
|
|
|
|
} else { |
208
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
if ($attr[13]) { # backward_arrow == 1 |
212
|
0
|
|
|
|
|
|
$line = nextline($fh); |
213
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
214
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
215
|
|
|
|
|
|
|
} else { |
216
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
|
if ($attr[0] == 5) { # sub_type == 5 |
220
|
0
|
|
|
|
|
|
$line = nextline($fh); |
221
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
222
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
223
|
|
|
|
|
|
|
} else { |
224
|
0
|
|
|
|
|
|
push @attr, (undef,undef); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
my $npoints = $attr[14]; |
228
|
0
|
|
|
|
|
|
my(@xnpoints, @ynpoints); |
229
|
0
|
|
|
|
|
|
until ($npoints == 0) { |
230
|
0
|
|
|
|
|
|
$line = nextline($fh); |
231
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
232
|
0
|
|
|
|
|
|
my @points = split / /, $line; |
233
|
0
|
|
|
|
|
|
$npoints -= (scalar(@points) / 2); |
234
|
0
|
|
|
|
|
|
while (@points) { |
235
|
0
|
|
|
|
|
|
push @xnpoints, (shift @points); |
236
|
0
|
|
|
|
|
|
push @ynpoints, (shift @points); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
241
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
242
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
243
|
|
|
|
|
|
|
} |
244
|
0
|
|
|
|
|
|
$object = new Polyline($name,@attr,\@xnpoints,\@ynpoints,$self); |
245
|
0
|
|
|
|
|
|
$object->calculateCenter(); |
246
|
0
|
|
|
|
|
|
push @{$current->{polylines}}, $name; |
|
0
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
248
|
0
|
|
|
|
|
|
$name = ""; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
elsif ($object_code eq "3") { # Spline |
252
|
0
|
0
|
|
|
|
|
if ($attr[10]) { # forward_arrow == 1 |
253
|
0
|
|
|
|
|
|
$line = nextline($fh); |
254
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
255
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
256
|
|
|
|
|
|
|
} else { |
257
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
0
|
0
|
|
|
|
|
if ($attr[11]) { # backward_arrow == 1 |
261
|
0
|
|
|
|
|
|
$line = nextline($fh); |
262
|
0
|
|
|
|
|
|
$line =~ s/^\t//; |
263
|
0
|
|
|
|
|
|
push @attr, (split / /, $line); |
264
|
|
|
|
|
|
|
} else { |
265
|
0
|
|
|
|
|
|
push @attr, (undef,undef,undef,undef,undef); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
my $npoints = $attr[12]; |
269
|
0
|
|
|
|
|
|
my(@xnpoints, @ynpoints); |
270
|
0
|
|
|
|
|
|
until ($npoints == 0) { |
271
|
0
|
|
|
|
|
|
$line = nextline($fh); |
272
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
273
|
0
|
|
|
|
|
|
my @points = split / /, $line; |
274
|
0
|
|
|
|
|
|
$npoints -= (scalar(@points) / 2); |
275
|
0
|
|
|
|
|
|
while (@points) { |
276
|
0
|
|
|
|
|
|
push @xnpoints, (shift @points); |
277
|
0
|
|
|
|
|
|
push @ynpoints, (shift @points); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
$npoints = $attr[12]; |
282
|
0
|
|
|
|
|
|
my @control_points; |
283
|
0
|
|
|
|
|
|
until ($npoints == 0) { |
284
|
0
|
|
|
|
|
|
$line = nextline($fh); |
285
|
0
|
|
|
|
|
|
$line =~ s/^[\t ]*//; |
286
|
0
|
|
|
|
|
|
my @points = split / /, $line; |
287
|
0
|
|
|
|
|
|
$npoints -= scalar(@points); |
288
|
0
|
|
|
|
|
|
push @control_points, @points; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
292
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
293
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
294
|
|
|
|
|
|
|
} |
295
|
0
|
|
|
|
|
|
$object = new Spline($name,@attr,\@xnpoints,\@ynpoints, |
296
|
|
|
|
|
|
|
\@control_points,$self); |
297
|
0
|
|
|
|
|
|
$object->calculateCenter(); |
298
|
0
|
|
|
|
|
|
push @{$current->{splines}}, $name; |
|
0
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
300
|
0
|
|
|
|
|
|
$name = ""; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
elsif ($object_code eq "4") { # Text |
304
|
0
|
|
|
|
|
|
my @new_attr = @attr[0..11]; |
305
|
0
|
|
|
|
|
|
my $chaine = ""; |
306
|
0
|
|
|
|
|
|
for (12..(scalar(@attr) - 1)) { |
307
|
0
|
|
|
|
|
|
$chaine .= $attr[$_] . " "; |
308
|
|
|
|
|
|
|
} |
309
|
0
|
|
|
|
|
|
$chaine =~ s/\\001 $//; |
310
|
0
|
|
|
|
|
|
push @new_attr, $chaine; |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
$name =~ s/\n$//; |
313
|
0
|
0
|
0
|
|
|
|
if (($name =~ /^\n*$/) || (defined $self->{objects}->{$name})) { |
314
|
0
|
|
|
|
|
|
$name = sprintf("untitled%04d", $self->{num}++); |
315
|
|
|
|
|
|
|
} |
316
|
0
|
|
|
|
|
|
$object = new Text($name,@new_attr,$self); |
317
|
0
|
|
|
|
|
|
$object->calculateCenter(); |
318
|
0
|
|
|
|
|
|
push @{$current->{texts}}, $name; |
|
0
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
$self->{objects}->{$name} = $object; |
320
|
0
|
|
|
|
|
|
$name = ""; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
else { |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# printer |
331
|
|
|
|
|
|
|
sub writeFile { |
332
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
333
|
0
|
|
|
|
|
|
my $filename = shift; |
334
|
|
|
|
|
|
|
|
335
|
0
|
0
|
|
|
|
|
open OUT, ">$filename" or die "Can't open $filename : $!\n"; |
336
|
|
|
|
|
|
|
|
337
|
0
|
|
|
|
|
|
$self->writeHeader(\*OUT); |
338
|
0
|
|
|
|
|
|
$self->writeObjects(\*OUT); |
339
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
|
close OUT; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub writeHeader { |
344
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
345
|
0
|
|
|
|
|
|
my $fh = shift; |
346
|
|
|
|
|
|
|
|
347
|
0
|
|
|
|
|
|
printf $fh "#FIG %s\n", $self->{version}; |
348
|
0
|
|
|
|
|
|
printf $fh "%s\n", $self->{orientation}; |
349
|
0
|
|
|
|
|
|
printf $fh "%s\n", $self->{justification}; |
350
|
0
|
|
|
|
|
|
printf $fh "%s\n", $self->{units}; |
351
|
0
|
|
|
|
|
|
printf $fh "%s\n", $self->{papersize}; |
352
|
0
|
|
|
|
|
|
printf $fh "%.2f\n", $self->{magnification}; |
353
|
0
|
|
|
|
|
|
printf $fh "%s\n", $self->{multiple_page}; |
354
|
0
|
|
|
|
|
|
printf $fh "%d\n", $self->{transparent_color}; |
355
|
0
|
0
|
|
|
|
|
if ($self->{title} ne "") { |
356
|
0
|
|
|
|
|
|
foreach (split(/\n/, $self->{title})) { |
357
|
0
|
|
|
|
|
|
printf $fh "# $_\n"; |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
} |
360
|
0
|
|
|
|
|
|
printf $fh "%d %d\n", $self->{resolution}, $self->{coord_system}; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub writeObjects { |
364
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
365
|
0
|
|
|
|
|
|
my $fh = shift; |
366
|
|
|
|
|
|
|
|
367
|
0
|
|
|
|
|
|
foreach (@{$self->{colors}}) { |
|
0
|
|
|
|
|
|
|
368
|
0
|
|
|
|
|
|
$_->output($fh); |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
0
|
|
|
|
|
|
foreach (@{$self->{arcs}}) { |
|
0
|
|
|
|
|
|
|
372
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
376
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
foreach (@{$self->{ellipses}}) { |
|
0
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
0
|
|
|
|
|
|
foreach (@{$self->{polylines}}) { |
|
0
|
|
|
|
|
|
|
384
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
foreach (@{$self->{splines}}) { |
|
0
|
|
|
|
|
|
|
388
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
foreach (@{$self->{texts}}) { |
|
0
|
|
|
|
|
|
|
392
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->output($fh); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
# scheduler |
398
|
|
|
|
|
|
|
sub generateGif { |
399
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
400
|
0
|
|
|
|
|
|
my $file = shift; |
401
|
0
|
|
|
|
|
|
my $speed = shift; |
402
|
0
|
|
|
|
|
|
my $loop = shift; |
403
|
0
|
|
|
|
|
|
my $wait = shift; |
404
|
0
|
0
|
|
|
|
|
$wait = 0 if (!(defined $wait)); |
405
|
|
|
|
|
|
|
|
406
|
0
|
|
|
|
|
|
my $length = 1; |
407
|
0
|
|
|
|
|
|
for (my $i=0; $i{animations}}); $i++) { |
|
0
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# calculates the number of frames = first frame + number of frames of the each animation |
409
|
0
|
|
|
|
|
|
my $count = sprintf("%.0f",$self->{animations}[$i][2]*$speed) + |
410
|
|
|
|
|
|
|
sprintf("%.0f",$self->{animations}[$i][3]*$speed); |
411
|
0
|
0
|
|
|
|
|
$length = $count if ($count > $length); # we choose the biggest number of frame |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
0
|
|
|
|
|
|
my $last = $self->clone(); # The first frame is the copy of the static image |
415
|
0
|
|
|
|
|
|
for (my $f=0; $f<=$length; $f++) { # for each frame do |
416
|
0
|
|
|
|
|
|
my $current = $last->clone(); # the current frame is the copy of precedent |
417
|
0
|
|
|
|
|
|
for (my $i=0; $i{animations}}); $i++) { # for each animation do |
|
0
|
|
|
|
|
|
|
418
|
0
|
|
|
|
|
|
my $firstframe = sprintf("%.0f",$self->{animations}[$i][2]*$speed); |
419
|
0
|
|
|
|
|
|
my $nbframes = sprintf("%.0f",$self->{animations}[$i][3]*$speed); |
420
|
0
|
0
|
0
|
|
|
|
if (($f > $firstframe) && ($f <= $firstframe+$nbframes)) { |
|
|
0
|
|
|
|
|
|
421
|
|
|
|
|
|
|
# if the current frame is inside the current animation do |
422
|
|
|
|
|
|
|
|
423
|
0
|
0
|
0
|
|
|
|
if ($self->{animations}[$i][0] == 1) { # changeThickness |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
424
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
425
|
0
|
|
|
|
|
|
my $inc = $self->{animations}[$i][5]; |
426
|
|
|
|
|
|
|
|
427
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{thickness} = |
428
|
|
|
|
|
|
|
$last->{objects}->{$name}->{thickness} + $inc; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 2) { # changeFillIntensity |
432
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
433
|
0
|
|
|
|
|
|
my $inc = $self->{animations}[$i][5]; |
434
|
|
|
|
|
|
|
|
435
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{area_fill} = |
436
|
|
|
|
|
|
|
$last->{objects}->{$name}->{area_fill} + $inc; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 11) { # translate Ellipse |
440
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
441
|
0
|
|
|
|
|
|
my $inc_x = $self->{animations}[$i][7]; |
442
|
0
|
|
|
|
|
|
my $inc_y = $self->{animations}[$i][8]; |
443
|
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
445
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $inc_x; |
446
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
447
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $inc_y; |
448
|
|
|
|
|
|
|
|
449
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_x} = |
450
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_x} + $inc_x; |
451
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_y} = |
452
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_y} + $inc_y; |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_x} = |
455
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_x} + $inc_x; |
456
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_y} = |
457
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_y} + $inc_y; |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 12) || # translate |
460
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 13)) { # Polyline/Spline |
461
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
462
|
0
|
|
|
|
|
|
my $inc_x = $self->{animations}[$i][7]; |
463
|
0
|
|
|
|
|
|
my $inc_y = $self->{animations}[$i][8]; |
464
|
|
|
|
|
|
|
|
465
|
0
|
|
|
|
|
|
for (my $i=0; $i<$current->{objects}->{$name}->{npoints}; |
466
|
|
|
|
|
|
|
$i++) { |
467
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{xnpoints}[$i] = |
468
|
|
|
|
|
|
|
$last->{objects}->{$name}->{xnpoints}[$i] + $inc_x; |
469
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{ynpoints}[$i] = |
470
|
|
|
|
|
|
|
$last->{objects}->{$name}->{ynpoints}[$i] + $inc_y; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
474
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $inc_x; |
475
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
476
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $inc_y; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 14) { # translate Text |
479
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
480
|
0
|
|
|
|
|
|
my $inc_x = $self->{animations}[$i][7]; |
481
|
0
|
|
|
|
|
|
my $inc_y = $self->{animations}[$i][8]; |
482
|
|
|
|
|
|
|
|
483
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x} = |
484
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x} + $inc_x; |
485
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y} = |
486
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y} + $inc_y; |
487
|
|
|
|
|
|
|
|
488
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
489
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $inc_x; |
490
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
491
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $inc_y; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 15) { # translate Arc |
494
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
495
|
0
|
|
|
|
|
|
my $inc_x = $self->{animations}[$i][7]; |
496
|
0
|
|
|
|
|
|
my $inc_y = $self->{animations}[$i][8]; |
497
|
|
|
|
|
|
|
|
498
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
499
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $inc_x; |
500
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
501
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $inc_y; |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x1} = |
504
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x1} + $inc_x; |
505
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y1} = |
506
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y1} + $inc_y; |
507
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x2} = |
509
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x2} + $inc_x; |
510
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y2} = |
511
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y2} + $inc_y; |
512
|
|
|
|
|
|
|
|
513
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x3} = |
514
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x3} + $inc_x; |
515
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y3} = |
516
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y3} + $inc_y; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 16) { # translate Compound |
519
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
520
|
0
|
|
|
|
|
|
my $inc_x = $self->{animations}[$i][7]; |
521
|
0
|
|
|
|
|
|
my $inc_y = $self->{animations}[$i][8]; |
522
|
|
|
|
|
|
|
|
523
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_x} = |
524
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_x}+$inc_x; |
525
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_y} = |
526
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_y}+$inc_y; |
527
|
|
|
|
|
|
|
|
528
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_x} = |
529
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_x}+$inc_x; |
530
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_y} = |
531
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_y}+$inc_y; |
532
|
|
|
|
|
|
|
|
533
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
534
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $inc_x; |
535
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
536
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $inc_y; |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 21) { # rotate Ellipse |
540
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
541
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
542
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
543
|
0
|
|
|
|
|
|
my $inc_angle = $self->{animations}[$i][8]; |
544
|
0
|
|
|
|
|
|
my ($r,$a); |
545
|
|
|
|
|
|
|
|
546
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
547
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x}-$c_x, |
548
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y}-$c_y, |
549
|
|
|
|
|
|
|
0); |
550
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x}, |
551
|
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y}) = |
552
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
553
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} += $c_x; |
554
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} += $c_y; |
555
|
|
|
|
|
|
|
|
556
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
557
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_x}-$c_x, |
558
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_y}-$c_y, |
559
|
|
|
|
|
|
|
0); |
560
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{start_x}, |
561
|
|
|
|
|
|
|
$current->{objects}->{$name}->{start_y}) = |
562
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
563
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_x} += $c_x; |
564
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_y} += $c_y; |
565
|
|
|
|
|
|
|
|
566
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
567
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_x}-$c_x, |
568
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_y}-$c_y, |
569
|
|
|
|
|
|
|
0); |
570
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{end_x}, |
571
|
|
|
|
|
|
|
$current->{objects}->{$name}->{end_y}) = |
572
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
573
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_x} += $c_x; |
574
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_y} += $c_y; |
575
|
|
|
|
|
|
|
|
576
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{angle} = |
577
|
|
|
|
|
|
|
$last->{objects}->{$name}->{angle} - $inc_angle; |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 22) || # rotate |
580
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 23)) { # Polyline/Spline |
581
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
582
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
583
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
584
|
0
|
|
|
|
|
|
my $inc_angle = $self->{animations}[$i][8]; |
585
|
0
|
|
|
|
|
|
my ($r,$a); |
586
|
|
|
|
|
|
|
|
587
|
0
|
|
|
|
|
|
for (my $i=0; $i<$current->{objects}->{$name}->{npoints}; |
588
|
|
|
|
|
|
|
$i++) { |
589
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
590
|
|
|
|
|
|
|
$last->{objects}->{$name}->{xnpoints}[$i] |
591
|
|
|
|
|
|
|
- $c_x, |
592
|
|
|
|
|
|
|
$last->{objects}->{$name}->{ynpoints}[$i] |
593
|
|
|
|
|
|
|
- $c_y, |
594
|
|
|
|
|
|
|
0); |
595
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{xnpoints}[$i], |
596
|
|
|
|
|
|
|
$current->{objects}->{$name}->{ynpoints}[$i]) = |
597
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
598
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{xnpoints}[$i] += $c_x; |
599
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{ynpoints}[$i] += $c_y; |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
603
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x}-$c_x, |
604
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y}-$c_y, |
605
|
|
|
|
|
|
|
0); |
606
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x}, |
607
|
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y}) = |
608
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
609
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} += $c_x; |
610
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} += $c_y; |
611
|
|
|
|
|
|
|
} |
612
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 24) { # rotate Text |
613
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
614
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
615
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
616
|
0
|
|
|
|
|
|
my $inc_angle = $self->{animations}[$i][8]; |
617
|
0
|
|
|
|
|
|
my ($r,$a); |
618
|
|
|
|
|
|
|
|
619
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
620
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x}-$c_x, |
621
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y}-$c_y, |
622
|
|
|
|
|
|
|
0); |
623
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{x}, |
624
|
|
|
|
|
|
|
$current->{objects}->{$name}->{y}) = |
625
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
626
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x} += $c_x; |
627
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y} += $c_y; |
628
|
|
|
|
|
|
|
|
629
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{angle} = |
630
|
|
|
|
|
|
|
$last->{objects}->{$name}->{angle} - $inc_angle; |
631
|
|
|
|
|
|
|
|
632
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
633
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x}-$c_x, |
634
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y}-$c_y, |
635
|
|
|
|
|
|
|
0); |
636
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x}, |
637
|
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y}) = |
638
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
639
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} += $c_x; |
640
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} += $c_y; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 25) { # rotate Arc |
643
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
644
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
645
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
646
|
0
|
|
|
|
|
|
my $inc_angle = $self->{animations}[$i][8]; |
647
|
0
|
|
|
|
|
|
my ($r,$a); |
648
|
|
|
|
|
|
|
|
649
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
650
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x}-$c_x, |
651
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y}-$c_y, |
652
|
|
|
|
|
|
|
0); |
653
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x}, |
654
|
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y}) = |
655
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
656
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} += $c_x; |
657
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} += $c_y; |
658
|
|
|
|
|
|
|
|
659
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
660
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x1}-$c_x, |
661
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y1}-$c_y, |
662
|
|
|
|
|
|
|
0); |
663
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{x1}, |
664
|
|
|
|
|
|
|
$current->{objects}->{$name}->{y1}) = |
665
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
666
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x1} += $c_x; |
667
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y1} += $c_y; |
668
|
|
|
|
|
|
|
|
669
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
670
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x2}-$c_x, |
671
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y2}-$c_y, |
672
|
|
|
|
|
|
|
0); |
673
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{x2}, |
674
|
|
|
|
|
|
|
$current->{objects}->{$name}->{y2}) = |
675
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
676
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x2} += $c_x; |
677
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y2} += $c_y; |
678
|
|
|
|
|
|
|
|
679
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
680
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x3}-$c_x, |
681
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y3}-$c_y, |
682
|
|
|
|
|
|
|
0); |
683
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{x3}, |
684
|
|
|
|
|
|
|
$current->{objects}->{$name}->{y3}) = |
685
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
686
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x3} += $c_x; |
687
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y3} += $c_y; |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 26) { # rotate Compound |
690
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
691
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
692
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
693
|
0
|
|
|
|
|
|
my $inc_angle = $self->{animations}[$i][8]; |
694
|
0
|
|
|
|
|
|
my ($r,$a); |
695
|
|
|
|
|
|
|
|
696
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
697
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_x}-$c_x, |
698
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_y}-$c_y, |
699
|
|
|
|
|
|
|
0); |
700
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{upperleft_corner_x}, |
701
|
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_y}) = |
702
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
703
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_x} += $c_x; |
704
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_y} += $c_y; |
705
|
|
|
|
|
|
|
|
706
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
707
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_x}-$c_x, |
708
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_y}-$c_y, |
709
|
|
|
|
|
|
|
0); |
710
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{lowerright_corner_x}, |
711
|
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_y}) = |
712
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
713
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_x} +=$c_x; |
714
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_y} +=$c_y; |
715
|
|
|
|
|
|
|
|
716
|
0
|
|
|
|
|
|
($r,$a) = cartesian_to_cylindrical( |
717
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x}-$c_x, |
718
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y}-$c_y, |
719
|
|
|
|
|
|
|
0); |
720
|
0
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x}, |
721
|
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y}) = |
722
|
|
|
|
|
|
|
cylindrical_to_cartesian($r,$a+$inc_angle,0); |
723
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} += $c_x; |
724
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} += $c_y; |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 31) { # scale Ellipse |
728
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
729
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
730
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
731
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
732
|
0
|
|
|
|
|
|
my @incs_x = @{$self->{animations}[$i][7]}; |
|
0
|
|
|
|
|
|
|
733
|
0
|
|
|
|
|
|
my @incs_y = @{$self->{animations}[$i][8]}; |
|
0
|
|
|
|
|
|
|
734
|
0
|
|
|
|
|
|
my $r_x = $self->{animations}[$i][9]; |
735
|
0
|
|
|
|
|
|
my $r_y = $self->{animations}[$i][10]; |
736
|
|
|
|
|
|
|
|
737
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
738
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $incs_x[0]; |
739
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
740
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $incs_y[0]; |
741
|
|
|
|
|
|
|
|
742
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_x} = |
743
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_x} + $incs_x[1]; |
744
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{start_y} = |
745
|
|
|
|
|
|
|
$last->{objects}->{$name}->{start_y} + $incs_y[1]; |
746
|
|
|
|
|
|
|
|
747
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_x} = |
748
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_x} + $incs_x[2]; |
749
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{end_y} = |
750
|
|
|
|
|
|
|
$last->{objects}->{$name}->{end_y} + $incs_y[2]; |
751
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{radius_x} = |
753
|
|
|
|
|
|
|
$last->{objects}->{$name}->{radius_x} + $r_x; |
754
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{radius_y} = |
755
|
|
|
|
|
|
|
$last->{objects}->{$name}->{radius_y} + $r_y; |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 32) || # scale |
758
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 33)) { # Polyline/Spline |
759
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
760
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
761
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
762
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
763
|
0
|
|
|
|
|
|
my @incs_x = @{$self->{animations}[$i][7]}; |
|
0
|
|
|
|
|
|
|
764
|
0
|
|
|
|
|
|
my @incs_y = @{$self->{animations}[$i][8]}; |
|
0
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
|
766
|
0
|
|
|
|
|
|
for (my $i=0; $i<$current->{objects}->{$name}->{npoints}; |
767
|
|
|
|
|
|
|
$i++) { |
768
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{xnpoints}[$i] = |
769
|
|
|
|
|
|
|
$last->{objects}->{$name}->{xnpoints}[$i] + |
770
|
|
|
|
|
|
|
$incs_x[$i]; |
771
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{ynpoints}[$i] = |
772
|
|
|
|
|
|
|
$last->{objects}->{$name}->{ynpoints}[$i] + |
773
|
|
|
|
|
|
|
$incs_y[$i]; |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
|
776
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
777
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + |
778
|
|
|
|
|
|
|
$incs_x[$current->{objects}->{$name}->{npoints}]; |
779
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
780
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + |
781
|
|
|
|
|
|
|
$incs_y[$current->{objects}->{$name}->{npoints}]; |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 34) { # scale Text |
784
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
785
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
786
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
787
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
788
|
0
|
|
|
|
|
|
my @incs_x = @{$self->{animations}[$i][7]}; |
|
0
|
|
|
|
|
|
|
789
|
0
|
|
|
|
|
|
my @incs_y = @{$self->{animations}[$i][8]}; |
|
0
|
|
|
|
|
|
|
790
|
0
|
|
|
|
|
|
my $font_size = $self->{animations}[$i][9]; |
791
|
0
|
|
|
|
|
|
my $height = $self->{animations}[$i][10]; |
792
|
|
|
|
|
|
|
|
793
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x} = |
794
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x} + $incs_x[0]; |
795
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y} = |
796
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y} + $incs_y[0]; |
797
|
|
|
|
|
|
|
|
798
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
799
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $incs_x[1]; |
800
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
801
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $incs_y[1]; |
802
|
|
|
|
|
|
|
|
803
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{font_size} = |
804
|
|
|
|
|
|
|
$last->{objects}->{$name}->{font_size} + $font_size; |
805
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{height} = |
806
|
|
|
|
|
|
|
$last->{objects}->{$name}->{height} + $height; |
807
|
|
|
|
|
|
|
} |
808
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 35) { # scale Arc |
809
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
810
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
811
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
812
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
813
|
0
|
|
|
|
|
|
my @incs_x = @{$self->{animations}[$i][7]}; |
|
0
|
|
|
|
|
|
|
814
|
0
|
|
|
|
|
|
my @incs_y = @{$self->{animations}[$i][8]}; |
|
0
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
|
816
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
817
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $incs_x[0]; |
818
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
819
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $incs_y[0]; |
820
|
|
|
|
|
|
|
|
821
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x1} = |
822
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x1} + $incs_x[1]; |
823
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y1} = |
824
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y1} + $incs_y[1]; |
825
|
|
|
|
|
|
|
|
826
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x2} = |
827
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x2} + $incs_x[2]; |
828
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y2} = |
829
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y2} + $incs_y[2]; |
830
|
|
|
|
|
|
|
|
831
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{x3} = |
832
|
|
|
|
|
|
|
$last->{objects}->{$name}->{x3} + $incs_x[3]; |
833
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{y3} = |
834
|
|
|
|
|
|
|
$last->{objects}->{$name}->{y3} + $incs_y[3]; |
835
|
|
|
|
|
|
|
} |
836
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 36) { # scale Compound |
837
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
838
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
839
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
840
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
841
|
0
|
|
|
|
|
|
my @incs_x = @{$self->{animations}[$i][7]}; |
|
0
|
|
|
|
|
|
|
842
|
0
|
|
|
|
|
|
my @incs_y = @{$self->{animations}[$i][8]}; |
|
0
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
|
844
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_x} = |
845
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_x} + |
846
|
|
|
|
|
|
|
$incs_x[0]; |
847
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{upperleft_corner_y} = |
848
|
|
|
|
|
|
|
$last->{objects}->{$name}->{upperleft_corner_y} + |
849
|
|
|
|
|
|
|
$incs_y[0]; |
850
|
|
|
|
|
|
|
|
851
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_x} = |
852
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_x} + |
853
|
|
|
|
|
|
|
$incs_x[1]; |
854
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{lowerright_corner_y} = |
855
|
|
|
|
|
|
|
$last->{objects}->{$name}->{lowerright_corner_y} + |
856
|
|
|
|
|
|
|
$incs_y[1]; |
857
|
|
|
|
|
|
|
|
858
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_x} = |
859
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_x} + $incs_x[2]; |
860
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{center_y} = |
861
|
|
|
|
|
|
|
$last->{objects}->{$name}->{center_y} + $incs_y[2]; |
862
|
|
|
|
|
|
|
} |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
} elsif ($f == $firstframe) { # if the current frame is the first frame then initiate increment |
865
|
|
|
|
|
|
|
|
866
|
0
|
0
|
0
|
|
|
|
if ($self->{animations}[$i][0] == 0) { # setAttributeValue |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
867
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
868
|
0
|
|
|
|
|
|
my $attribute = $self->{animations}[$i][4]; |
869
|
0
|
|
|
|
|
|
my $value = $self->{animations}[$i][5]; |
870
|
|
|
|
|
|
|
|
871
|
0
|
|
|
|
|
|
$current->{objects}->{$name}->{$attribute} = $value; |
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 1) { # changeThickness |
875
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
876
|
0
|
|
|
|
|
|
my $thickness = $self->{animations}[$i][4]; |
877
|
|
|
|
|
|
|
|
878
|
0
|
|
|
|
|
|
my $firstthick = $current->{objects}->{$name}->{thickness}; |
879
|
0
|
|
|
|
|
|
$self->{animations}[$i][5] = |
880
|
|
|
|
|
|
|
($thickness-$firstthick) / $nbframes; |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 2) { # changeFillIntensity |
884
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
885
|
0
|
|
|
|
|
|
my $intensity = $self->{animations}[$i][4]; |
886
|
|
|
|
|
|
|
|
887
|
0
|
|
|
|
|
|
my $firstinten = $current->{objects}->{$name}->{area_fill}; |
888
|
0
|
|
|
|
|
|
$self->{animations}[$i][5] = |
889
|
|
|
|
|
|
|
($intensity-$firstinten) / $nbframes; |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 11) || |
893
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 12) || |
894
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 13) || |
895
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 14) || |
896
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 15) || |
897
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 16)) { # translate |
898
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
899
|
0
|
|
|
|
|
|
my $x = $self->{animations}[$i][4]; |
900
|
0
|
|
|
|
|
|
my $y = $self->{animations}[$i][5]; |
901
|
0
|
|
|
|
|
|
my $unit = $self->{animations}[$i][6]; |
902
|
|
|
|
|
|
|
|
903
|
0
|
0
|
|
|
|
|
if ($unit eq 'in') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
904
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = 1200 * $x / $nbframes; |
905
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = 1200 * $y / $nbframes; |
906
|
|
|
|
|
|
|
} elsif ($unit eq 'cm') { |
907
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = 450 * $x / $nbframes; |
908
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = 450 * $y / $nbframes; |
909
|
|
|
|
|
|
|
} elsif ($unit eq 'px') { |
910
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = 15 * $x / $nbframes; |
911
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = 15 * $y / $nbframes; |
912
|
|
|
|
|
|
|
} else { |
913
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = $x / $nbframes; |
914
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = $y / $nbframes; |
915
|
|
|
|
|
|
|
} |
916
|
|
|
|
|
|
|
} |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 21) || |
919
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 22) || |
920
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 23) || |
921
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 24) || |
922
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 25) || |
923
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 26)) { # rotate |
924
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
925
|
0
|
|
|
|
|
|
my $angle = $self->{animations}[$i][4]; |
926
|
|
|
|
|
|
|
|
927
|
0
|
0
|
|
|
|
|
if ($self->{animations}[$i][7] eq 'in') { # $unit eq 'in' |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
928
|
0
|
|
|
|
|
|
$self->{animations}[$i][5] *= 1200; # $c_x *= 1200 |
929
|
0
|
|
|
|
|
|
$self->{animations}[$i][6] *= 1200; # $c_y *= 1200 |
930
|
|
|
|
|
|
|
} elsif ($self->{animations}[$i][7] eq 'cm') { |
931
|
0
|
|
|
|
|
|
$self->{animations}[$i][5] *= 450; |
932
|
0
|
|
|
|
|
|
$self->{animations}[$i][6] *= 450; |
933
|
|
|
|
|
|
|
} elsif ($self->{animations}[$i][7] eq 'px') { |
934
|
0
|
|
|
|
|
|
$self->{animations}[$i][5] *= 15; |
935
|
0
|
|
|
|
|
|
$self->{animations}[$i][6] *= 15; |
936
|
|
|
|
|
|
|
} |
937
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = ''; # $unit = '' |
938
|
|
|
|
|
|
|
|
939
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = deg2rad($angle / $nbframes); |
940
|
|
|
|
|
|
|
} |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 31) { # scale Ellipse |
943
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
944
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
945
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
946
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
947
|
0
|
|
|
|
|
|
my (@incs_x,@incs_y); |
948
|
|
|
|
|
|
|
|
949
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
950
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x} - |
951
|
|
|
|
|
|
|
$c_x) / $nbframes); |
952
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
953
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_y} - |
954
|
|
|
|
|
|
|
$c_y) / $nbframes); |
955
|
|
|
|
|
|
|
|
956
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
957
|
|
|
|
|
|
|
($current->{objects}->{$name}->{start_x} - |
958
|
|
|
|
|
|
|
$c_x) / $nbframes); |
959
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
960
|
|
|
|
|
|
|
($current->{objects}->{$name}->{start_y} - |
961
|
|
|
|
|
|
|
$c_y) / $nbframes); |
962
|
|
|
|
|
|
|
|
963
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
964
|
|
|
|
|
|
|
($current->{objects}->{$name}->{end_x} - |
965
|
|
|
|
|
|
|
$c_x) / $nbframes); |
966
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
967
|
|
|
|
|
|
|
($current->{objects}->{$name}->{end_y} - |
968
|
|
|
|
|
|
|
$c_y) / $nbframes); |
969
|
|
|
|
|
|
|
|
970
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = \@incs_x; |
971
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = \@incs_y; |
972
|
|
|
|
|
|
|
|
973
|
0
|
|
|
|
|
|
$self->{animations}[$i][9] = ($scale - 1) * |
974
|
|
|
|
|
|
|
$current->{objects}->{$name}->{radius_x} / $nbframes; |
975
|
0
|
|
|
|
|
|
$self->{animations}[$i][10] = ($scale - 1) * |
976
|
|
|
|
|
|
|
$current->{objects}->{$name}->{radius_y} / $nbframes; |
977
|
|
|
|
|
|
|
} |
978
|
|
|
|
|
|
|
elsif (($self->{animations}[$i][0] == 32) || # scale |
979
|
|
|
|
|
|
|
($self->{animations}[$i][0] == 33)) { # Polyline/Spline |
980
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
981
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
982
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
983
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
984
|
0
|
|
|
|
|
|
my (@incs_x,@incs_y); |
985
|
|
|
|
|
|
|
|
986
|
0
|
|
|
|
|
|
for (my $i=0; $i<$current->{objects}->{$name}->{npoints}; |
987
|
|
|
|
|
|
|
$i++) { |
988
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
989
|
|
|
|
|
|
|
($current->{objects}->{$name}->{xnpoints}[$i] |
990
|
|
|
|
|
|
|
- $c_x) / $nbframes); |
991
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
992
|
|
|
|
|
|
|
($current->{objects}->{$name}->{ynpoints}[$i] |
993
|
|
|
|
|
|
|
- $c_y) / $nbframes); |
994
|
|
|
|
|
|
|
} |
995
|
|
|
|
|
|
|
|
996
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
997
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x} - |
998
|
|
|
|
|
|
|
$c_x) / $nbframes); |
999
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1000
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_y} - |
1001
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1002
|
|
|
|
|
|
|
|
1003
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = \@incs_x; |
1004
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = \@incs_y; |
1005
|
|
|
|
|
|
|
} |
1006
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 34) { # scale Text |
1007
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
1008
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
1009
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
1010
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
1011
|
0
|
|
|
|
|
|
my (@incs_x,@incs_y); |
1012
|
|
|
|
|
|
|
|
1013
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1014
|
|
|
|
|
|
|
($current->{objects}->{$name}->{x} - |
1015
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1016
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1017
|
|
|
|
|
|
|
($current->{objects}->{$name}->{y} - |
1018
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1019
|
|
|
|
|
|
|
|
1020
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1021
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x} - |
1022
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1023
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1024
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_y} - |
1025
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1026
|
|
|
|
|
|
|
|
1027
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = \@incs_x; |
1028
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = \@incs_y; |
1029
|
|
|
|
|
|
|
|
1030
|
0
|
|
|
|
|
|
$self->{animations}[$i][9] = ($scale - 1) * |
1031
|
|
|
|
|
|
|
$current->{objects}->{$name}->{font_size} / $nbframes; |
1032
|
0
|
|
|
|
|
|
$self->{animations}[$i][10] = ($scale - 1) * |
1033
|
|
|
|
|
|
|
$current->{objects}->{$name}->{height} / $nbframes; |
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 35) { # scale Arc |
1036
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
1037
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
1038
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
1039
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
1040
|
0
|
|
|
|
|
|
my (@incs_x,@incs_y); |
1041
|
|
|
|
|
|
|
|
1042
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1043
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x} - |
1044
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1045
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1046
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_y} - |
1047
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1048
|
|
|
|
|
|
|
|
1049
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1050
|
|
|
|
|
|
|
($current->{objects}->{$name}->{x1} - |
1051
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1052
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1053
|
|
|
|
|
|
|
($current->{objects}->{$name}->{y1} - |
1054
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1055
|
|
|
|
|
|
|
|
1056
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1057
|
|
|
|
|
|
|
($current->{objects}->{$name}->{x2} - |
1058
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1059
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1060
|
|
|
|
|
|
|
($current->{objects}->{$name}->{y2} - |
1061
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1062
|
|
|
|
|
|
|
|
1063
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1064
|
|
|
|
|
|
|
($current->{objects}->{$name}->{x3} - |
1065
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1066
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1067
|
|
|
|
|
|
|
($current->{objects}->{$name}->{y3} - |
1068
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1069
|
|
|
|
|
|
|
|
1070
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = \@incs_x; |
1071
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = \@incs_y; |
1072
|
|
|
|
|
|
|
} |
1073
|
|
|
|
|
|
|
elsif ($self->{animations}[$i][0] == 36) { # scale Compound |
1074
|
0
|
|
|
|
|
|
my $name = $self->{animations}[$i][1]; |
1075
|
0
|
|
|
|
|
|
my $scale = $self->{animations}[$i][4]; |
1076
|
0
|
|
|
|
|
|
my $c_x = $self->{animations}[$i][5]; |
1077
|
0
|
|
|
|
|
|
my $c_y = $self->{animations}[$i][6]; |
1078
|
0
|
|
|
|
|
|
my (@incs_x,@incs_y); |
1079
|
|
|
|
|
|
|
|
1080
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1081
|
|
|
|
|
|
|
($current->{objects}->{$name}->{upperleft_corner_x} |
1082
|
|
|
|
|
|
|
- $c_x) / $nbframes); |
1083
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1084
|
|
|
|
|
|
|
($current->{objects}->{$name}->{upperleft_corner_y} |
1085
|
|
|
|
|
|
|
- $c_y) / $nbframes); |
1086
|
|
|
|
|
|
|
|
1087
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1088
|
|
|
|
|
|
|
($current->{objects}->{$name}->{lowerright_corner_x} |
1089
|
|
|
|
|
|
|
- $c_x) / $nbframes); |
1090
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1091
|
|
|
|
|
|
|
($current->{objects}->{$name}->{lowerright_corner_y} |
1092
|
|
|
|
|
|
|
- $c_y) / $nbframes); |
1093
|
|
|
|
|
|
|
|
1094
|
0
|
|
|
|
|
|
push @incs_x, (($scale-1) * |
1095
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_x} - |
1096
|
|
|
|
|
|
|
$c_x) / $nbframes); |
1097
|
0
|
|
|
|
|
|
push @incs_y, (($scale-1) * |
1098
|
|
|
|
|
|
|
($current->{objects}->{$name}->{center_y} - |
1099
|
|
|
|
|
|
|
$c_y) / $nbframes); |
1100
|
|
|
|
|
|
|
|
1101
|
0
|
|
|
|
|
|
$self->{animations}[$i][7] = \@incs_x; |
1102
|
0
|
|
|
|
|
|
$self->{animations}[$i][8] = \@incs_y; |
1103
|
|
|
|
|
|
|
} |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
} |
1106
|
0
|
|
|
|
|
|
my $framename = sprintf(".frame%04d",$f); |
1107
|
0
|
|
|
|
|
|
$current->writeFile($framename.".fig"); |
1108
|
0
|
|
|
|
|
|
`fig2dev -L gif $framename.fig $framename.gif`; |
1109
|
0
|
|
|
|
|
|
`rm $framename.fig`; |
1110
|
0
|
|
|
|
|
|
$last = $current; # the current frame becomes the last frame |
1111
|
|
|
|
|
|
|
} |
1112
|
|
|
|
|
|
|
} |
1113
|
|
|
|
|
|
|
# possible optimization |
1114
|
0
|
|
|
|
|
|
my $delay = 100 / $speed; |
1115
|
0
|
|
|
|
|
|
my $final_delay = $delay + $wait * 100; |
1116
|
0
|
|
|
|
|
|
my @frames = split /\n/, `ls .frame????.gif`; |
1117
|
0
|
|
|
|
|
|
`convert -loop $loop -delay $delay @frames[0..$length-1] -delay $final_delay $frames[$length] $file`; |
1118
|
0
|
|
|
|
|
|
`rm @frames`; |
1119
|
|
|
|
|
|
|
} |
1120
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
# objects selectors |
1123
|
|
|
|
|
|
|
sub selectByType { |
1124
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1125
|
0
|
|
|
|
|
|
my $res = new Compound("",0,0,0,0,$self); |
1126
|
|
|
|
|
|
|
|
1127
|
0
|
|
|
|
|
|
foreach (@_) { |
1128
|
0
|
|
|
|
|
|
push @{$res->{$_}}, @{$self->{$_}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
} |
1130
|
|
|
|
|
|
|
|
1131
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1132
|
0
|
|
|
|
|
|
my $aux = $self->{objects}->{$_}->selectByType(@_); |
1133
|
0
|
|
|
|
|
|
foreach (@_) { |
1134
|
0
|
|
|
|
|
|
push @{$res->{$_}}, @{$aux->{$_}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
} |
1137
|
|
|
|
|
|
|
|
1138
|
0
|
|
|
|
|
|
return $res; |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
sub selectByPenColor { |
1142
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1143
|
0
|
|
|
|
|
|
my $res = new Compound("",0,0,0,0,$self); |
1144
|
|
|
|
|
|
|
|
1145
|
0
|
|
|
|
|
|
foreach (@_) { |
1146
|
0
|
|
|
|
|
|
my $color = $FigAnim::Utils::colors_codes{$_}; |
1147
|
0
|
0
|
|
|
|
|
if (defined $color) { |
1148
|
0
|
|
|
|
|
|
foreach (@{$self->{arcs}}) { |
|
0
|
|
|
|
|
|
|
1149
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{pen_color} == $color) { |
1150
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, $_; |
|
0
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
} |
1152
|
|
|
|
|
|
|
} |
1153
|
0
|
|
|
|
|
|
foreach (@{$self->{ellipses}}) { |
|
0
|
|
|
|
|
|
|
1154
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{pen_color} == $color) { |
1155
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, $_; |
|
0
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
} |
1157
|
|
|
|
|
|
|
} |
1158
|
0
|
|
|
|
|
|
foreach (@{$self->{polylines}}) { |
|
0
|
|
|
|
|
|
|
1159
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{pen_color} == $color) { |
1160
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, $_; |
|
0
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
} |
1162
|
|
|
|
|
|
|
} |
1163
|
0
|
|
|
|
|
|
foreach (@{$self->{splines}}) { |
|
0
|
|
|
|
|
|
|
1164
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{pen_color} == $color) { |
1165
|
0
|
|
|
|
|
|
push @{$res->{splines}}, $_; |
|
0
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
} |
1167
|
|
|
|
|
|
|
} |
1168
|
0
|
|
|
|
|
|
foreach (@{$self->{texts}}) { |
|
0
|
|
|
|
|
|
|
1169
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{pen_color} == $color) { |
1170
|
0
|
|
|
|
|
|
push @{$res->{texts}}, $_; |
|
0
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
} |
1172
|
|
|
|
|
|
|
} |
1173
|
|
|
|
|
|
|
} |
1174
|
|
|
|
|
|
|
} |
1175
|
|
|
|
|
|
|
|
1176
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1177
|
0
|
|
|
|
|
|
my $aux = $self->{objects}->{$_}->selectByPenColor(@_); |
1178
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, @{$aux->{arcs}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1179
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, @{$aux->{ellipses}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1180
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, @{$aux->{polylines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1181
|
0
|
|
|
|
|
|
push @{$res->{splines}}, @{$aux->{splines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1182
|
0
|
|
|
|
|
|
push @{$res->{texts}}, @{$aux->{texts}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
} |
1184
|
|
|
|
|
|
|
|
1185
|
0
|
|
|
|
|
|
return $res; |
1186
|
|
|
|
|
|
|
} |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
sub selectByFillColor { |
1189
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1190
|
0
|
|
|
|
|
|
my $res = new Compound("",0,0,0,0,$self); |
1191
|
|
|
|
|
|
|
|
1192
|
0
|
|
|
|
|
|
foreach (@_) { |
1193
|
0
|
|
|
|
|
|
my $color = $FigAnim::Utils::colors_codes{$_}; |
1194
|
0
|
0
|
|
|
|
|
if (defined $color) { |
1195
|
0
|
|
|
|
|
|
foreach (@{$self->{arcs}}) { |
|
0
|
|
|
|
|
|
|
1196
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{fill_color} == $color) { |
1197
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, $_; |
|
0
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
} |
1199
|
|
|
|
|
|
|
} |
1200
|
0
|
|
|
|
|
|
foreach (@{$self->{ellipses}}) { |
|
0
|
|
|
|
|
|
|
1201
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{fill_color} == $color) { |
1202
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, $_; |
|
0
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
} |
1204
|
|
|
|
|
|
|
} |
1205
|
0
|
|
|
|
|
|
foreach (@{$self->{polylines}}) { |
|
0
|
|
|
|
|
|
|
1206
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{fill_color} == $color) { |
1207
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, $_; |
|
0
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
} |
1210
|
0
|
|
|
|
|
|
foreach (@{$self->{splines}}) { |
|
0
|
|
|
|
|
|
|
1211
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$_}->{fill_color} == $color) { |
1212
|
0
|
|
|
|
|
|
push @{$res->{splines}}, $_; |
|
0
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
} |
1214
|
|
|
|
|
|
|
} |
1215
|
|
|
|
|
|
|
} |
1216
|
|
|
|
|
|
|
} |
1217
|
|
|
|
|
|
|
|
1218
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1219
|
0
|
|
|
|
|
|
my $aux = $self->{objects}->{$_}->selectByFillColor(@_); |
1220
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, @{$aux->{arcs}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1221
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, @{$aux->{ellipses}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1222
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, @{$aux->{polylines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1223
|
0
|
|
|
|
|
|
push @{$res->{splines}}, @{$aux->{splines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
} |
1225
|
|
|
|
|
|
|
|
1226
|
0
|
|
|
|
|
|
return $res; |
1227
|
|
|
|
|
|
|
} |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
sub selectByAttributeValue { |
1230
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1231
|
0
|
|
|
|
|
|
my $res = new Compound("",0,0,0,0,$self); |
1232
|
0
|
|
|
|
|
|
my @params = @_; |
1233
|
|
|
|
|
|
|
|
1234
|
0
|
|
|
|
|
|
while (@params) { |
1235
|
0
|
|
|
|
|
|
my $attribute = shift @params; |
1236
|
0
|
|
|
|
|
|
my $value = shift @params; |
1237
|
|
|
|
|
|
|
|
1238
|
0
|
|
|
|
|
|
foreach (@{$self->{arcs}}) { |
|
0
|
|
|
|
|
|
|
1239
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1240
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1241
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, $_; |
|
0
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
} |
1243
|
|
|
|
|
|
|
} |
1244
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1245
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1246
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1247
|
0
|
|
|
|
|
|
push @{$res->{compounds}}, $_; |
|
0
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
} |
1250
|
0
|
|
|
|
|
|
foreach (@{$self->{ellipses}}) { |
|
0
|
|
|
|
|
|
|
1251
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1252
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1253
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, $_; |
|
0
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
} |
1255
|
|
|
|
|
|
|
} |
1256
|
0
|
|
|
|
|
|
foreach (@{$self->{polylines}}) { |
|
0
|
|
|
|
|
|
|
1257
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1258
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1259
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, $_; |
|
0
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
} |
1261
|
|
|
|
|
|
|
} |
1262
|
0
|
|
|
|
|
|
foreach (@{$self->{splines}}) { |
|
0
|
|
|
|
|
|
|
1263
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1264
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1265
|
0
|
|
|
|
|
|
push @{$res->{splines}}, $_; |
|
0
|
|
|
|
|
|
|
1266
|
|
|
|
|
|
|
} |
1267
|
|
|
|
|
|
|
} |
1268
|
0
|
|
|
|
|
|
foreach (@{$self->{texts}}) { |
|
0
|
|
|
|
|
|
|
1269
|
0
|
0
|
0
|
|
|
|
if ((defined $self->{objects}->{$_}->{$attribute}) && |
1270
|
|
|
|
|
|
|
($self->{objects}->{$_}->{$attribute} eq $value)) { |
1271
|
0
|
|
|
|
|
|
push @{$res->{texts}}, $_; |
|
0
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
} |
1273
|
|
|
|
|
|
|
} |
1274
|
|
|
|
|
|
|
} |
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
|
1277
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1278
|
0
|
|
|
|
|
|
my $aux = $self->{objects}->{$_}->selectByAttributeValue(@_); |
1279
|
0
|
|
|
|
|
|
push @{$res->{arcs}}, @{$aux->{arcs}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1280
|
0
|
|
|
|
|
|
push @{$res->{compounds}}, @{$aux->{compounds}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1281
|
0
|
|
|
|
|
|
push @{$res->{ellipses}}, @{$aux->{ellipses}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1282
|
0
|
|
|
|
|
|
push @{$res->{polylines}}, @{$aux->{polylines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1283
|
0
|
|
|
|
|
|
push @{$res->{splines}}, @{$aux->{splines}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1284
|
0
|
|
|
|
|
|
push @{$res->{texts}}, @{$aux->{texts}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
} |
1286
|
|
|
|
|
|
|
|
1287
|
0
|
|
|
|
|
|
return $res; |
1288
|
|
|
|
|
|
|
} |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
# writes a SVG file |
1292
|
|
|
|
|
|
|
sub writeSVGFile { |
1293
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1294
|
0
|
|
|
|
|
|
my $filename = shift; |
1295
|
|
|
|
|
|
|
|
1296
|
0
|
0
|
|
|
|
|
open OUT, ">$filename" or die "Can't open $filename : $!\n"; |
1297
|
|
|
|
|
|
|
|
1298
|
0
|
|
|
|
|
|
$self->writeSVGHeader(\*OUT); |
1299
|
0
|
|
|
|
|
|
$self->writeSVGObjects(\*OUT); |
1300
|
|
|
|
|
|
|
|
1301
|
0
|
|
|
|
|
|
print OUT "\n"; |
1302
|
|
|
|
|
|
|
|
1303
|
0
|
|
|
|
|
|
close OUT; |
1304
|
|
|
|
|
|
|
} |
1305
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
# writes SVG header |
1307
|
|
|
|
|
|
|
sub writeSVGHeader { |
1308
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1309
|
0
|
|
|
|
|
|
my $fh = shift; |
1310
|
|
|
|
|
|
|
|
1311
|
0
|
|
|
|
|
|
print $fh "\n"; |
1312
|
0
|
|
|
|
|
|
print $fh "
|
1313
|
0
|
|
|
|
|
|
print $fh "\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n\n"; |
1314
|
|
|
|
|
|
|
|
1315
|
0
|
|
|
|
|
|
print $fh " |
1316
|
|
|
|
|
|
|
|
1317
|
0
|
|
|
|
|
|
print $fh |
1318
|
|
|
|
|
|
|
ConvertSVG::papersize_to_units($self->{papersize}, |
1319
|
|
|
|
|
|
|
$self->{orientation}, |
1320
|
|
|
|
|
|
|
$self->{magnification}, |
1321
|
|
|
|
|
|
|
$self->{resolution}); |
1322
|
0
|
|
|
|
|
|
print $fh ">\n"; |
1323
|
|
|
|
|
|
|
|
1324
|
0
|
|
|
|
|
|
print $fh ""; |
1325
|
0
|
0
|
|
|
|
|
print $fh split(/\n/, $self->{title}, 0) if ($self->{title}); |
1326
|
0
|
|
|
|
|
|
print $fh "\n"; |
1327
|
|
|
|
|
|
|
|
1328
|
0
|
|
|
|
|
|
print $fh "\n"; |
1329
|
0
|
0
|
|
|
|
|
if ($self->{title} ne "") { |
1330
|
0
|
|
|
|
|
|
foreach (split(/\n/, $self->{title})) { |
1331
|
0
|
|
|
|
|
|
print $fh "$_\n"; |
1332
|
|
|
|
|
|
|
} |
1333
|
|
|
|
|
|
|
} |
1334
|
0
|
|
|
|
|
|
print $fh "\n\n"; |
1335
|
|
|
|
|
|
|
} |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
# write SVG objects |
1338
|
|
|
|
|
|
|
sub writeSVGObjects { |
1339
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1340
|
0
|
|
|
|
|
|
my $fh = shift; |
1341
|
|
|
|
|
|
|
|
1342
|
0
|
|
|
|
|
|
my @objects; |
1343
|
0
|
|
|
|
|
|
push @objects, @{$self->{arcs}}; |
|
0
|
|
|
|
|
|
|
1344
|
0
|
|
|
|
|
|
push @objects, @{$self->{ellipses}}; |
|
0
|
|
|
|
|
|
|
1345
|
0
|
|
|
|
|
|
push @objects, @{$self->{polylines}}; |
|
0
|
|
|
|
|
|
|
1346
|
0
|
|
|
|
|
|
push @objects, @{$self->{splines}}; |
|
0
|
|
|
|
|
|
|
1347
|
0
|
|
|
|
|
|
push @objects, @{$self->{texts}}; |
|
0
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
# sorts objects by depth |
1350
|
|
|
|
|
|
|
@objects = |
1351
|
|
|
|
|
|
|
sort { |
1352
|
0
|
0
|
|
|
|
|
if ($self->{objects}->{$a}->{depth} < |
|
0
|
0
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
$self->{objects}->{$b}->{depth}) { |
1354
|
0
|
|
|
|
|
|
return 1; |
1355
|
|
|
|
|
|
|
} elsif ($self->{objects}->{$a}->{depth} == |
1356
|
|
|
|
|
|
|
$self->{objects}->{$b}->{depth}) { |
1357
|
0
|
|
|
|
|
|
return 0; |
1358
|
|
|
|
|
|
|
} else { |
1359
|
0
|
|
|
|
|
|
return -1; |
1360
|
|
|
|
|
|
|
} |
1361
|
|
|
|
|
|
|
} @objects; |
1362
|
|
|
|
|
|
|
|
1363
|
0
|
|
|
|
|
|
foreach (@objects) { |
1364
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->outputSVG($fh, \@{$self->{colors}}); |
|
0
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
} |
1366
|
|
|
|
|
|
|
|
1367
|
0
|
|
|
|
|
|
foreach (@{$self->{compounds}}) { |
|
0
|
|
|
|
|
|
|
1368
|
0
|
|
|
|
|
|
$self->{objects}->{$_}->outputSVG($fh, \@{$self->{colors}}); |
|
0
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
} |
1370
|
|
|
|
|
|
|
} |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
sub generateSMIL { |
1374
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1375
|
0
|
|
|
|
|
|
my $file = shift; |
1376
|
|
|
|
|
|
|
|
1377
|
0
|
0
|
|
|
|
|
open OUT, ">$file" or die "Can't open $file : $!\n"; |
1378
|
|
|
|
|
|
|
|
1379
|
0
|
|
|
|
|
|
$self->writeSVGHeader(\*OUT); |
1380
|
0
|
|
|
|
|
|
$self->writeSMILObjects(\*OUT); |
1381
|
|
|
|
|
|
|
|
1382
|
0
|
|
|
|
|
|
print OUT "\n"; |
1383
|
|
|
|
|
|
|
|
1384
|
0
|
|
|
|
|
|
close OUT; |
1385
|
|
|
|
|
|
|
} |
1386
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
sub writeSMILObjects { |
1388
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
1389
|
0
|
|
|
|
|
|
my $fh = shift; |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
# sorts animations by start time |
1392
|
0
|
|
|
|
|
|
@{$self->{animations}} = |
1393
|
|
|
|
|
|
|
sort { |
1394
|
0
|
0
|
|
|
|
|
if (@$a[2] < @$b[2]) { return -1; } |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1395
|
0
|
|
|
|
|
|
elsif (@$a[2] == @$b[2]) { return 0; } |
1396
|
0
|
|
|
|
|
|
else { return 1; } |
1397
|
0
|
|
|
|
|
|
} @{$self->{animations}}; |
1398
|
|
|
|
|
|
|
|
1399
|
0
|
|
|
|
|
|
my @setAttributeValue; |
1400
|
|
|
|
|
|
|
my @changeThickness; |
1401
|
0
|
|
|
|
|
|
my @changeFillIntensity; |
1402
|
0
|
|
|
|
|
|
my @translate; |
1403
|
0
|
|
|
|
|
|
my @rotate; |
1404
|
0
|
|
|
|
|
|
my @scale; |
1405
|
|
|
|
|
|
|
|
1406
|
0
|
|
|
|
|
|
for (my $i = 0; $i <= $#{$self->{animations}}; $i++) { |
|
0
|
|
|
|
|
|
|
1407
|
0
|
0
|
0
|
|
|
|
if ($self->{animations}[$i][0] == 0) { # setAttributeValue (0) |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1408
|
0
|
|
|
|
|
|
push @setAttributeValue, $self->{animations}[$i]; |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
} elsif ($self->{animations}[$i][0] == 1) { # changeThickness (1) |
1411
|
0
|
|
|
|
|
|
push @changeThickness, $self->{animations}[$i]; |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
} elsif ($self->{animations}[$i][0] == 2) { # changeFillIntensity (2) |
1414
|
0
|
|
|
|
|
|
push @changeFillIntensity, $self->{animations}[$i]; |
1415
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
} elsif (($self->{animations}[$i][0] >= 11) && |
1417
|
|
|
|
|
|
|
($self->{animations}[$i][0] <= 16)) { # translate (11 - 16) |
1418
|
0
|
|
|
|
|
|
push @translate, $self->{animations}[$i]; |
1419
|
|
|
|
|
|
|
|
1420
|
|
|
|
|
|
|
} elsif (($self->{animations}[$i][0] >= 21) && |
1421
|
|
|
|
|
|
|
($self->{animations}[$i][0] <= 26)) { # rotate (21 - 26) |
1422
|
0
|
|
|
|
|
|
push @rotate, $self->{animations}[$i]; |
1423
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
} elsif (($self->{animations}[$i][0] >= 31) && |
1425
|
|
|
|
|
|
|
($self->{animations}[$i][0] <= 36)) { # scale (31 - 36) |
1426
|
0
|
|
|
|
|
|
push @scale, $self->{animations}[$i]; |
1427
|
|
|
|
|
|
|
} |
1428
|
|
|
|
|
|
|
} |
1429
|
|
|
|
|
|
|
|
1430
|
0
|
|
|
|
|
|
my $i; |
1431
|
|
|
|
|
|
|
|
1432
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#setAttributeValue; $i++) { |
1433
|
0
|
|
|
|
|
|
my $name = $setAttributeValue[$i][1]; |
1434
|
0
|
|
|
|
|
|
my $begin = $setAttributeValue[$i][2]; |
1435
|
0
|
|
|
|
|
|
my $dur = $setAttributeValue[$i][3]; |
1436
|
0
|
|
|
|
|
|
my $attribute = $setAttributeValue[$i][4]; |
1437
|
0
|
|
|
|
|
|
my $value = $setAttributeValue[$i][5]; |
1438
|
|
|
|
|
|
|
|
1439
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1440
|
|
|
|
|
|
|
|
1441
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = 0; # type |
1442
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $begin; # begin |
1443
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $dur; # dur |
1444
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $attribute; # attr |
1445
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $value; # value |
1446
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][5] = |
1447
|
0
|
|
|
|
|
|
\@{$self->{colors}}; # colors |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
|
1450
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#changeThickness; $i++) { |
1451
|
0
|
|
|
|
|
|
my $name = $changeThickness[$i][1]; |
1452
|
0
|
|
|
|
|
|
my $begin = $changeThickness[$i][2]; |
1453
|
0
|
|
|
|
|
|
my $dur = $changeThickness[$i][3]; |
1454
|
0
|
|
|
|
|
|
my $to = $changeThickness[$i][4]; |
1455
|
0
|
|
|
|
|
|
my $from; |
1456
|
|
|
|
|
|
|
|
1457
|
0
|
|
|
|
|
|
my $j = $i; |
1458
|
0
|
|
0
|
|
|
|
do { |
1459
|
0
|
|
|
|
|
|
$j--; |
1460
|
|
|
|
|
|
|
} while (($j >= 0) && ($name ne $changeThickness[$j][1])); |
1461
|
|
|
|
|
|
|
|
1462
|
0
|
0
|
|
|
|
|
if ($j == -1) { |
1463
|
0
|
|
|
|
|
|
$from = $self->{objects}->{$name}->{thickness}; |
1464
|
|
|
|
|
|
|
} else { |
1465
|
0
|
|
|
|
|
|
$from = $changeThickness[$j][4]; |
1466
|
|
|
|
|
|
|
} |
1467
|
|
|
|
|
|
|
|
1468
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
|
1470
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = 1; # type |
1471
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $from; # from |
1472
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $to; # to |
1473
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $begin; # begin |
1474
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $dur; # dur |
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
|
1477
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#changeFillIntensity; $i++) { |
1478
|
0
|
|
|
|
|
|
my $name = $changeFillIntensity[$i][1]; |
1479
|
0
|
|
|
|
|
|
my $begin = $changeFillIntensity[$i][2]; |
1480
|
0
|
|
|
|
|
|
my $dur = $changeFillIntensity[$i][3]; |
1481
|
0
|
|
|
|
|
|
my $to = $changeFillIntensity[$i][4]; |
1482
|
0
|
|
|
|
|
|
my $from; |
1483
|
|
|
|
|
|
|
|
1484
|
0
|
|
|
|
|
|
my $j = $i; |
1485
|
0
|
|
0
|
|
|
|
do { |
1486
|
0
|
|
|
|
|
|
$j--; |
1487
|
|
|
|
|
|
|
} while (($j >= 0) && ($name ne $changeFillIntensity[$j][1])); |
1488
|
|
|
|
|
|
|
|
1489
|
0
|
0
|
|
|
|
|
if ($j == -1) { |
1490
|
0
|
|
|
|
|
|
$from = $self->{objects}->{$name}->{area_fill}; |
1491
|
|
|
|
|
|
|
} else { |
1492
|
0
|
|
|
|
|
|
$from = $changeFillIntensity[$j][4]; |
1493
|
|
|
|
|
|
|
} |
1494
|
|
|
|
|
|
|
|
1495
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1496
|
|
|
|
|
|
|
|
1497
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = 2; # type |
1498
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $begin; # from |
1499
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $dur; # to |
1500
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $from; # begin |
1501
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $to; # dur |
1502
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][5] = |
1503
|
|
|
|
|
|
|
$self->{objects}->{$name}->{fill_color}; # color |
1504
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][6] = |
1505
|
0
|
|
|
|
|
|
\@{$self->{colors}}; # colors |
1506
|
|
|
|
|
|
|
} |
1507
|
|
|
|
|
|
|
|
1508
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#translate; $i++) { |
1509
|
0
|
|
|
|
|
|
my $type = $translate[$i][0]; |
1510
|
0
|
|
|
|
|
|
my $name = $translate[$i][1]; |
1511
|
0
|
|
|
|
|
|
my $begin = $translate[$i][2]; |
1512
|
0
|
|
|
|
|
|
my $dur = $translate[$i][3]; |
1513
|
0
|
|
|
|
|
|
my $x = $translate[$i][4]; |
1514
|
0
|
|
|
|
|
|
my $y = $translate[$i][5]; |
1515
|
0
|
|
|
|
|
|
my $unit = $translate[$i][6]; |
1516
|
|
|
|
|
|
|
|
1517
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
|
1519
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = $type; # type |
1520
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $begin; # begin |
1521
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $dur; # dur |
1522
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $x; # x |
1523
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $y; # y |
1524
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][5] = $unit; # unit |
1525
|
|
|
|
|
|
|
} |
1526
|
|
|
|
|
|
|
|
1527
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#rotate; $i++) { |
1528
|
0
|
|
|
|
|
|
my $type = $rotate[$i][0]; |
1529
|
0
|
|
|
|
|
|
my $name = $rotate[$i][1]; |
1530
|
0
|
|
|
|
|
|
my $begin = $rotate[$i][2]; |
1531
|
0
|
|
|
|
|
|
my $dur = $rotate[$i][3]; |
1532
|
0
|
|
|
|
|
|
my $angle = $rotate[$i][4]; |
1533
|
0
|
|
|
|
|
|
my $x = $rotate[$i][5]; |
1534
|
0
|
|
|
|
|
|
my $y = $rotate[$i][6]; |
1535
|
0
|
|
|
|
|
|
my $unit = $rotate[$i][7]; |
1536
|
|
|
|
|
|
|
|
1537
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
|
1539
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = $type; # type |
1540
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $begin; # begin |
1541
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $dur; # dur |
1542
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $angle; # angle |
1543
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $x; # x |
1544
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][5] = $y; # y |
1545
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][6] = $unit; # unit |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
0
|
|
|
|
|
|
for ($i = 0; $i <= $#scale; $i++) { |
1549
|
0
|
|
|
|
|
|
my $type = $scale[$i][0]; |
1550
|
0
|
|
|
|
|
|
my $name = $scale[$i][1]; |
1551
|
0
|
|
|
|
|
|
my $begin = $scale[$i][2]; |
1552
|
0
|
|
|
|
|
|
my $dur = $scale[$i][3]; |
1553
|
0
|
|
|
|
|
|
my $factor = $scale[$i][4]; |
1554
|
0
|
|
|
|
|
|
my $x = $scale[$i][5]; |
1555
|
0
|
|
|
|
|
|
my $y = $scale[$i][6]; |
1556
|
|
|
|
|
|
|
|
1557
|
0
|
|
|
|
|
|
my $last = $#{$self->{objects}->{$name}->{animations}} + 1; |
|
0
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
|
1559
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][0] = $type; # type |
1560
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][1] = $begin; # begin |
1561
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][2] = $dur; # dur |
1562
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][3] = $factor; # factor |
1563
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][4] = $x; # x |
1564
|
0
|
|
|
|
|
|
$self->{objects}->{$name}->{animations}[$last][5] = $y; # y |
1565
|
|
|
|
|
|
|
} |
1566
|
|
|
|
|
|
|
|
1567
|
0
|
|
|
|
|
|
$self->writeSVGObjects($fh); |
1568
|
|
|
|
|
|
|
} |
1569
|
|
|
|
|
|
|
|
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
# useful functions |
1572
|
|
|
|
|
|
|
sub nextline { |
1573
|
0
|
|
|
0
|
0
|
|
my $fh = shift; |
1574
|
0
|
0
|
|
|
|
|
if (eof $fh) { |
1575
|
0
|
|
|
|
|
|
return; |
1576
|
|
|
|
|
|
|
} |
1577
|
|
|
|
|
|
|
|
1578
|
0
|
|
|
|
|
|
my $line = <$fh>; |
1579
|
0
|
0
|
|
|
|
|
$line = nextline($fh) if ($line eq "\n"); |
1580
|
0
|
|
|
|
|
|
chomp $line; |
1581
|
0
|
|
|
|
|
|
return $line; |
1582
|
|
|
|
|
|
|
} |
1583
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
1; |
1586
|
|
|
|
|
|
|
__END__ |