svg2slides 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b61dbe513bf1dd3244e44490f69d3a79030a575a
4
+ data.tar.gz: 3f4dc0c03d155e3fb1f2d48b0b6767a8221af251
5
+ SHA512:
6
+ metadata.gz: 3c88fa854ad5af36a8d8383872cfc534f3816de4394ab56ec00a9a82f387d6fb423cc91b26742af07475fba48b7e5a6ac9be96dc43f89a766e70bcc997393cb9
7
+ data.tar.gz: 242d148e9106aafdac2579b9269787b8335fe45c81a6acfb68a64862e6d8445dfef875785557b6e53df6897e71746d13db84d64c853e5dfe94fea98b84104888
data/README ADDED
@@ -0,0 +1,83 @@
1
+ = SYNOPSIS
2
+
3
+ svg2slides - generates slides from layered SVG drawings
4
+
5
+ svg2slides reads SVG drawings that have layers and produces as output one SVG
6
+ per layer. The output SVG file for each layer has that layer and all the
7
+ layers below it, i.e. the layers above the current layer are removed from the
8
+ drawing. This is useful to generate sequences of slides, where slide N is
9
+ composed of layers 1, 2, ..., N of the original drawing.
10
+
11
+ = USAGE
12
+
13
+ svg2slides [OPTION] ... FILE [ FILE ...]
14
+
15
+ = OPTIONS
16
+
17
+ --help, -h:
18
+
19
+ Displays help
20
+
21
+ --version, -v:
22
+
23
+ Displays version information and exits.
24
+
25
+ --suffix SUFFIX
26
+
27
+ The suffix used for output filenames. Default: '-%03d'. This suffix will be
28
+ expanded as a printf(3) format string with the index of the given slide as
29
+ argument, and will be inserted between the basename of the input file and
30
+ the .svg extension to form the output file names.
31
+
32
+ Examples (assuming "file.svg" as an input file with 2 layers):
33
+
34
+ | Suffix | Output file names |
35
+ +--------+----------------------------+
36
+ | -%03d | file-001.svg, file-002.svg |
37
+ | _%d | file_1.svg, file_2.svg |
38
+
39
+ = MAKEFILE SNIPPET
40
+
41
+ Included in the package you'll find a Makefile snippet that you can include in
42
+ your own Makefile's to build slides from your SVG drawings. To do that, you
43
+ must declare the SVG2SLIDES_INPUT variable and after that include the snippet:
44
+
45
+ SVG2SLIDES_INPUT = drawing1.svg drawing2.svg
46
+ include /usr/share/svg2slides/svg2slides.mk
47
+ all: $(SVG2SLIDES_SLIDES)
48
+
49
+ This Makefile will build the slides in both drawing1.svg and drawing2.svg.
50
+
51
+ The you can make your own targets depend on $(SVG2SLIDES_SLIDES), which will
52
+ contain a list of all slides that will be generated from the files you listed
53
+ in the SVG2SLIDES_INPUT variable.
54
+
55
+ A `clean` target will be available automatically, so `make clean` will delete
56
+ the slides generated from your input files. If you need to add your own `clean`
57
+ target, make sure you do so with two colons ("clean::").
58
+
59
+ The Makefile snippet will be installed normally in
60
+ /usr/share/svg2slides/svg2slides.mk, but depending on your operating system it
61
+ may be in another place. It's intended to be used with GNU make.
62
+
63
+ = AUTHOR
64
+
65
+ Antonio Terceiro <terceiro@softwarelivre.org>
66
+
67
+ = COPYRIGHT
68
+
69
+ Copyright (c) 2009 Antonio Terceiro
70
+
71
+ This program is free software: you can redistribute it and/or modify
72
+ it under the terms of the GNU General Public License as published by
73
+ the Free Software Foundation, either version 3 of the License, or
74
+ (at your option) any later version.
75
+
76
+ This program is distributed in the hope that it will be useful,
77
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
78
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79
+ GNU General Public License for more details.
80
+
81
+ You should have received a copy of the GNU General Public License
82
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
83
+
@@ -0,0 +1,51 @@
1
+ task :default => :spec
2
+
3
+ task :spec do
4
+ ruby '-S', 'rspec', 'spec/'
5
+ end
6
+
7
+ require './lib/svg_2_slides.rb'
8
+ gem = 'svg2slides-' + Svg2Slides::VERSION + '.gem'
9
+ gemspec = gem + 'spec'
10
+
11
+ desc 'Builds .gemspec file'
12
+ file gemspec do
13
+ require 'rubygems'
14
+ require 'rubygems/package_task'
15
+ spec = Gem::Specification.new do |s|
16
+ s.platform = Gem::Platform::RUBY
17
+ s.summary = "Converts SVG drawings into slides"
18
+ s.executables = Dir.glob('bin/*').map { |f| File.basename(f) }
19
+ s.name = 'svg2slides'
20
+ s.author = 'Antonio Terceiro'
21
+ s.email = 'terceiro@softwarelivre.org'
22
+ s.version = Svg2Slides::VERSION
23
+ s.require_path = 'lib'
24
+ s.files = FileList['**/*']
25
+ s.description = <<-EOF
26
+ svg2slides takes a single SVG file with separate layers and creates one SVG
27
+ file for each layer. Each generated SVG file contains the corresponding layer and all the layers below it.
28
+ EOF
29
+ end
30
+ File.open(gemspec, 'w') do |f|
31
+ f.write(spec.to_ruby)
32
+ end
33
+ end
34
+
35
+ file gem => gemspec do
36
+ sh 'gem', 'build', gemspec
37
+ end
38
+
39
+ desc "Builds .gem file"
40
+ task 'gem' => gem
41
+
42
+ desc 'pushes .gem to rubygems.org'
43
+ task :push => gem do
44
+ sh 'gem', 'push', gem
45
+ end
46
+
47
+ desc 'cleanup'
48
+ task :clean do
49
+ rm_f FileList['*.gem']
50
+ rm_f FileList['*.gemspec']
51
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'svg_2_slides'
3
+ Svg2Slides.new.run
@@ -0,0 +1,12 @@
1
+ SVG2SLIDES_SLIDES = $(foreach input, $(SVG2SLIDES_INPUT), $(shell seq -f "$(shell echo $(input) | sed -e 's/.svg$$//')-%03g.svg" 1 $(shell grep -c 'inkscape:groupmode="layer"' $(input))))
2
+
3
+ -include svg2slides.in.mk
4
+
5
+ %.svg2slides.stamp: %.svg
6
+ svg2slides $< && touch $@
7
+
8
+ svg2slides.in.mk: $(SVG2SLIDES_INPUT)
9
+ for file in $(SVG2SLIDES_SLIDES); do input=`echo $$file | sed -e 's/-[0-9]*.svg/.svg2slides.stamp/'`; echo "$$file: $$input" >> $@; done
10
+
11
+ clean::
12
+ rm -rf $(SVG2SLIDES_SLIDES) svg2slides.in.mk *.svg2slides.stamp
@@ -0,0 +1,469 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+ xmlns:cc="http://creativecommons.org/ns#"
7
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+ xmlns:svg="http://www.w3.org/2000/svg"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
+ width="800"
13
+ height="744.09448"
14
+ id="svg2"
15
+ sodipodi:version="0.32"
16
+ inkscape:version="0.48.1 r9760"
17
+ version="1.0"
18
+ sodipodi:docname="how-it-works.svg"
19
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
20
+ <defs
21
+ id="defs4">
22
+ <marker
23
+ inkscape:stockid="Arrow2Lend"
24
+ orient="auto"
25
+ refY="0.0"
26
+ refX="0.0"
27
+ id="Arrow2Lend"
28
+ style="overflow:visible;">
29
+ <path
30
+ id="path3571"
31
+ style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
32
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
33
+ transform="scale(1.1) rotate(180) translate(1,0)" />
34
+ </marker>
35
+ <inkscape:perspective
36
+ sodipodi:type="inkscape:persp3d"
37
+ inkscape:vp_x="45.47476 : 526.18109 : 1"
38
+ inkscape:vp_y="6.1230318e-14 : 1000 : 0"
39
+ inkscape:vp_z="789.56924 : 526.18109 : 1"
40
+ inkscape:persp3d-origin="417.522 : 350.78739 : 1"
41
+ id="perspective10" />
42
+ </defs>
43
+ <sodipodi:namedview
44
+ id="base"
45
+ pagecolor="#ffffff"
46
+ bordercolor="#666666"
47
+ borderopacity="1.0"
48
+ inkscape:pageopacity="0.0"
49
+ inkscape:pageshadow="2"
50
+ inkscape:zoom="0.72437038"
51
+ inkscape:cx="400"
52
+ inkscape:cy="427.26761"
53
+ inkscape:document-units="px"
54
+ inkscape:current-layer="layer1"
55
+ showgrid="false"
56
+ width="1052.36px"
57
+ showguides="true"
58
+ inkscape:guide-bbox="true"
59
+ inkscape:window-width="1276"
60
+ inkscape:window-height="708"
61
+ inkscape:window-x="0"
62
+ inkscape:window-y="26"
63
+ inkscape:window-maximized="0">
64
+ <sodipodi:guide
65
+ orientation="1,0"
66
+ position="294.04847,450.04601"
67
+ id="guide3048" />
68
+ </sodipodi:namedview>
69
+ <metadata
70
+ id="metadata7">
71
+ <rdf:RDF>
72
+ <cc:Work
73
+ rdf:about="">
74
+ <dc:format>image/svg+xml</dc:format>
75
+ <dc:type
76
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
77
+ </cc:Work>
78
+ </rdf:RDF>
79
+ </metadata>
80
+ <g
81
+ inkscape:label="Camada 1"
82
+ inkscape:groupmode="layer"
83
+ id="layer1">
84
+ <path
85
+ style="fill:#fcaf3e;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
86
+ d="M 329.25145,392.75488 C 329.25145,392.75488 361.29972,395.37196 404.4892,348.06585 C 466.64522,279.98541 477.6562,265.2353 477.6562,265.2353 L 477.6562,547.37192 C 477.6562,547.37192 492.81044,567.24533 425.19684,481.10747 C 374.80826,416.9138 328.5612,414.15277 328.5612,414.15277 L 329.25145,392.75488 z"
87
+ id="path4848"
88
+ sodipodi:nodetypes="csccscc" />
89
+ <text
90
+ xml:space="preserve"
91
+ style="font-size:25.63043212999999909px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
92
+ x="87.695808"
93
+ y="80.112534"
94
+ id="text3403"
95
+ sodipodi:linespacing="125%"><tspan
96
+ sodipodi:role="line"
97
+ id="tspan3405"
98
+ x="87.695808"
99
+ y="80.112534">drawing.svg</tspan></text>
100
+ <g
101
+ id="g3415"
102
+ transform="translate(-78.62742,-137.77444)">
103
+ <path
104
+ sodipodi:nodetypes="cssscc"
105
+ id="path3409"
106
+ d="M 110.29283,423.10936 C 110.29283,423.10936 137.77443,298.52609 181.745,302.92315 C 225.71556,307.3202 206.66165,360.08489 241.8381,380.60448 C 277.01455,401.12408 301.59766,351.17269 331.24492,349.82509 C 363.49,348.3594 384.92565,423.10937 384.92565,423.10937 L 110.29283,423.10936 z"
107
+ style="fill:#8ae234;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
108
+ <rect
109
+ y="232.57025"
110
+ x="109.92641"
111
+ height="190.53911"
112
+ width="275.54886"
113
+ id="rect3407"
114
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
115
+ <text
116
+ id="text3411"
117
+ y="256.74744"
118
+ x="285.32919"
119
+ style="font-size:22.60144615px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#888a85;fill-opacity:1;stroke:none;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans"
120
+ xml:space="preserve"><tspan
121
+ y="256.74744"
122
+ x="285.32919"
123
+ id="tspan3413"
124
+ sodipodi:role="line">top layer</tspan></text>
125
+ </g>
126
+ <g
127
+ transform="translate(-78.62742,71.818588)"
128
+ id="g3421">
129
+ <rect
130
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
131
+ id="rect3425"
132
+ width="275.54886"
133
+ height="190.53911"
134
+ x="109.92641"
135
+ y="232.57025" />
136
+ <text
137
+ xml:space="preserve"
138
+ style="font-size:22.60144615px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#888a85;fill-opacity:1;stroke:none;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans"
139
+ x="249.32919"
140
+ y="256.74744"
141
+ id="text3427"><tspan
142
+ sodipodi:role="line"
143
+ id="tspan3429"
144
+ x="249.32919"
145
+ y="256.74744">middle layer</tspan></text>
146
+ <rect
147
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
148
+ id="rect3433"
149
+ width="26.382339"
150
+ height="23.450968"
151
+ x="167.82098"
152
+ y="284.60208" />
153
+ <path
154
+ style="fill:#ef2929;fill-rule:evenodd;stroke:#a40000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
155
+ d="M 162.46796,288.99914 L 198.74683,288.99914 L 180.11142,270.31165 L 162.46796,288.99914 z"
156
+ id="path3435"
157
+ sodipodi:nodetypes="cccc" />
158
+ </g>
159
+ <g
160
+ id="g3437"
161
+ transform="translate(-78.62742,278.48024)">
162
+ <rect
163
+ y="232.57025"
164
+ x="109.92641"
165
+ height="190.53911"
166
+ width="275.54886"
167
+ id="rect3441"
168
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
169
+ <text
170
+ id="text3443"
171
+ y="256.74744"
172
+ x="247.32919"
173
+ style="font-size:22.60144615px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#888a85;fill-opacity:1;stroke:none;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans"
174
+ xml:space="preserve"><tspan
175
+ y="256.74744"
176
+ x="247.32919"
177
+ id="tspan3445"
178
+ sodipodi:role="line">bottom layer</tspan></text>
179
+ <g
180
+ transform="translate(176.85978,-59.665571)"
181
+ id="g3461">
182
+ <rect
183
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
184
+ id="rect3463"
185
+ width="4.1455846"
186
+ height="22.282516"
187
+ x="79.343163"
188
+ y="425.42795" />
189
+ <path
190
+ sodipodi:type="star"
191
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
192
+ id="path3465"
193
+ sodipodi:sides="7"
194
+ sodipodi:cx="374.13901"
195
+ sodipodi:cy="326.94504"
196
+ sodipodi:r1="20.889233"
197
+ sodipodi:r2="17.417896"
198
+ sodipodi:arg1="0.80294022"
199
+ sodipodi:arg2="1.2517392"
200
+ inkscape:flatsided="false"
201
+ inkscape:rounded="0.5"
202
+ inkscape:randomized="0"
203
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
204
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)" />
205
+ </g>
206
+ <g
207
+ id="g3457"
208
+ transform="translate(166.85978,-61.665571)">
209
+ <rect
210
+ y="425.42795"
211
+ x="79.343163"
212
+ height="22.282516"
213
+ width="4.1455846"
214
+ id="rect3455"
215
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
216
+ <path
217
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)"
218
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
219
+ inkscape:randomized="0"
220
+ inkscape:rounded="0.5"
221
+ inkscape:flatsided="false"
222
+ sodipodi:arg2="1.2517392"
223
+ sodipodi:arg1="0.80294022"
224
+ sodipodi:r2="17.417896"
225
+ sodipodi:r1="20.889233"
226
+ sodipodi:cy="326.94504"
227
+ sodipodi:cx="374.13901"
228
+ sodipodi:sides="7"
229
+ id="path3453"
230
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
231
+ sodipodi:type="star" />
232
+ </g>
233
+ <g
234
+ id="g3467"
235
+ transform="translate(186.85978,-61.665571)">
236
+ <rect
237
+ y="425.42795"
238
+ x="79.343163"
239
+ height="22.282516"
240
+ width="4.1455846"
241
+ id="rect3469"
242
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
243
+ <path
244
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)"
245
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
246
+ inkscape:randomized="0"
247
+ inkscape:rounded="0.5"
248
+ inkscape:flatsided="false"
249
+ sodipodi:arg2="1.2517392"
250
+ sodipodi:arg1="0.80294022"
251
+ sodipodi:r2="17.417896"
252
+ sodipodi:r1="20.889233"
253
+ sodipodi:cy="326.94504"
254
+ sodipodi:cx="374.13901"
255
+ sodipodi:sides="7"
256
+ id="path3471"
257
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
258
+ sodipodi:type="star" />
259
+ </g>
260
+ </g>
261
+ <g
262
+ transform="translate(390.83315,-157.77444)"
263
+ id="g3473">
264
+ <path
265
+ style="fill:#8ae234;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
266
+ d="M 110.29283,423.10936 C 110.29283,423.10936 137.77443,298.52609 181.745,302.92315 C 225.71556,307.3202 206.66165,360.08489 241.8381,380.60448 C 277.01455,401.12408 301.59766,351.17269 331.24492,349.82509 C 363.49,348.3594 384.92565,423.10937 384.92565,423.10937 L 110.29283,423.10936 z"
267
+ id="path3475"
268
+ sodipodi:nodetypes="cssscc" />
269
+ <rect
270
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
271
+ id="rect3477"
272
+ width="275.54886"
273
+ height="190.53911"
274
+ x="109.92641"
275
+ y="232.57025" />
276
+ </g>
277
+ <g
278
+ id="g3483"
279
+ transform="translate(390.83315,71.818588)">
280
+ <path
281
+ sodipodi:nodetypes="cssscc"
282
+ id="path3485"
283
+ d="M 110.29283,423.10936 C 110.29283,423.10936 137.77443,298.52609 181.745,302.92315 C 225.71556,307.3202 206.66165,360.08489 241.8381,380.60448 C 277.01455,401.12408 301.59766,351.17269 331.24492,349.82509 C 363.49,348.3594 384.92565,423.10937 384.92565,423.10937 L 110.29283,423.10936 z"
284
+ style="fill:#8ae234;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
285
+ <rect
286
+ y="232.57025"
287
+ x="109.92641"
288
+ height="190.53911"
289
+ width="275.54886"
290
+ id="rect3487"
291
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
292
+ <rect
293
+ y="284.60208"
294
+ x="167.82098"
295
+ height="23.450968"
296
+ width="26.382339"
297
+ id="rect3493"
298
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
299
+ <path
300
+ sodipodi:nodetypes="cccc"
301
+ id="path3495"
302
+ d="M 162.46796,288.99914 L 198.74683,288.99914 L 180.11142,270.31165 L 162.46796,288.99914 z"
303
+ style="fill:#ef2929;fill-rule:evenodd;stroke:#a40000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
304
+ </g>
305
+ <g
306
+ transform="translate(390.83315,298.48024)"
307
+ id="g3497">
308
+ <path
309
+ style="fill:#8ae234;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
310
+ d="M 110.29283,423.10936 C 110.29283,423.10936 137.77443,298.52609 181.745,302.92315 C 225.71556,307.3202 206.66165,360.08489 241.8381,380.60448 C 277.01455,401.12408 301.59766,351.17269 331.24492,349.82509 C 363.49,348.3594 384.92565,423.10937 384.92565,423.10937 L 110.29283,423.10936 z"
311
+ id="path3499"
312
+ sodipodi:nodetypes="cssscc" />
313
+ <rect
314
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
315
+ id="rect3501"
316
+ width="275.54886"
317
+ height="190.53911"
318
+ x="109.92641"
319
+ y="232.57025" />
320
+ <rect
321
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
322
+ id="rect3507"
323
+ width="26.382339"
324
+ height="23.450968"
325
+ x="167.82098"
326
+ y="284.60208" />
327
+ <path
328
+ style="fill:#ef2929;fill-rule:evenodd;stroke:#a40000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
329
+ d="M 162.46796,288.99914 L 198.74683,288.99914 L 180.11142,270.31165 L 162.46796,288.99914 z"
330
+ id="path3509"
331
+ sodipodi:nodetypes="cccc" />
332
+ <g
333
+ id="g3511"
334
+ transform="translate(176.85978,-59.665571)">
335
+ <rect
336
+ y="425.42795"
337
+ x="79.343163"
338
+ height="22.282516"
339
+ width="4.1455846"
340
+ id="rect3513"
341
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
342
+ <path
343
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)"
344
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
345
+ inkscape:randomized="0"
346
+ inkscape:rounded="0.5"
347
+ inkscape:flatsided="false"
348
+ sodipodi:arg2="1.2517392"
349
+ sodipodi:arg1="0.80294022"
350
+ sodipodi:r2="17.417896"
351
+ sodipodi:r1="20.889233"
352
+ sodipodi:cy="326.94504"
353
+ sodipodi:cx="374.13901"
354
+ sodipodi:sides="7"
355
+ id="path3515"
356
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
357
+ sodipodi:type="star" />
358
+ </g>
359
+ <g
360
+ transform="translate(166.85978,-61.665571)"
361
+ id="g3517">
362
+ <rect
363
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
364
+ id="rect3519"
365
+ width="4.1455846"
366
+ height="22.282516"
367
+ x="79.343163"
368
+ y="425.42795" />
369
+ <path
370
+ sodipodi:type="star"
371
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
372
+ id="path3521"
373
+ sodipodi:sides="7"
374
+ sodipodi:cx="374.13901"
375
+ sodipodi:cy="326.94504"
376
+ sodipodi:r1="20.889233"
377
+ sodipodi:r2="17.417896"
378
+ sodipodi:arg1="0.80294022"
379
+ sodipodi:arg2="1.2517392"
380
+ inkscape:flatsided="false"
381
+ inkscape:rounded="0.5"
382
+ inkscape:randomized="0"
383
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
384
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)" />
385
+ </g>
386
+ <g
387
+ transform="translate(186.85978,-61.665571)"
388
+ id="g3523">
389
+ <rect
390
+ style="opacity:1;fill:#c17d11;fill-opacity:1;fill-rule:evenodd;stroke:#8f5902;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
391
+ id="rect3525"
392
+ width="4.1455846"
393
+ height="22.282516"
394
+ x="79.343163"
395
+ y="425.42795" />
396
+ <path
397
+ sodipodi:type="star"
398
+ style="opacity:1;fill:#73d216;fill-opacity:1;fill-rule:evenodd;stroke:#4e9a06;stroke-width:1.92549574;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
399
+ id="path3527"
400
+ sodipodi:sides="7"
401
+ sodipodi:cx="374.13901"
402
+ sodipodi:cy="326.94504"
403
+ sodipodi:r1="20.889233"
404
+ sodipodi:r2="17.417896"
405
+ sodipodi:arg1="0.80294022"
406
+ sodipodi:arg2="1.2517392"
407
+ inkscape:flatsided="false"
408
+ inkscape:rounded="0.5"
409
+ inkscape:randomized="0"
410
+ d="m 388.64855,341.97278 c -3.29895,3.1852 -4.69178,0.0727 -9.04605,1.5111 -4.35426,1.4384 -3.61895,4.76811 -8.1661,4.17482 -4.54716,-0.59329 -2.98212,-3.62286 -6.82155,-6.13033 -3.83942,-2.50747 -5.98424,0.14346 -8.35549,-3.78156 -2.37125,-3.92502 0.97315,-4.59033 0.53973,-9.1555 -0.43343,-4.56516 -3.84328,-4.58922 -2.25303,-8.89035 1.59026,-4.30113 4.19562,-2.10118 7.49457,-5.28638 3.29896,-3.1852 1.19176,-5.86613 5.54602,-7.30453 4.35427,-1.4384 4.2587,1.97019 8.80585,2.56348 4.54716,0.59329 5.32937,-2.72571 9.1688,-0.21824 3.83942,2.50747 1.11489,4.55798 3.48614,8.48299 2.37126,3.92502 5.45386,2.46722 5.88729,7.03238 0.43342,4.56517 -2.86845,3.71352 -4.4587,8.01464 -1.59025,4.30113 1.47148,5.80228 -1.82748,8.98748 z"
411
+ transform="matrix(0.5193296,0,0,0.5193639,-112.65926,252.14074)" />
412
+ </g>
413
+ </g>
414
+ <text
415
+ sodipodi:linespacing="125%"
416
+ id="text3529"
417
+ y="67.333138"
418
+ x="525.43091"
419
+ style="font-size:25.63043212999999909px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
420
+ xml:space="preserve"><tspan
421
+ y="67.333138"
422
+ x="525.43091"
423
+ id="tspan3531"
424
+ sodipodi:role="line">drawing-001.svg</tspan></text>
425
+ <text
426
+ xml:space="preserve"
427
+ style="font-size:25.63043212999999909px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
428
+ x="527.43091"
429
+ y="297.33313"
430
+ id="text3533"
431
+ sodipodi:linespacing="125%"><tspan
432
+ sodipodi:role="line"
433
+ id="tspan3535"
434
+ x="527.43091"
435
+ y="297.33313">drawing-002.svg</tspan></text>
436
+ <text
437
+ sodipodi:linespacing="125%"
438
+ id="text3537"
439
+ y="525.33313"
440
+ x="523.43091"
441
+ style="font-size:25.63043212999999909px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
442
+ xml:space="preserve"><tspan
443
+ y="525.33313"
444
+ x="523.43091"
445
+ id="tspan3539"
446
+ sodipodi:role="line">drawing-003.svg</tspan></text>
447
+ <path
448
+ sodipodi:nodetypes="csc"
449
+ id="path4327"
450
+ d="M 327.18069,414.15328 C 327.18069,414.15328 376.14403,421.81466 416.91379,470.75415 C 471.00664,535.68651 484.55874,552.2042 484.55874,552.2042"
451
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend);stroke-miterlimit:4;stroke-dasharray:none" />
452
+ <path
453
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow2Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
454
+ d="M 327.18069,393.75073 C 327.18069,393.75073 376.14403,386.08935 416.91379,337.14986 C 471.00664,272.2175 484.55874,255.69981 484.55874,255.69981"
455
+ id="path4846"
456
+ sodipodi:nodetypes="csc" />
457
+ <text
458
+ sodipodi:linespacing="125%"
459
+ id="text3044"
460
+ y="408.67374"
461
+ x="338.94849"
462
+ style="font-size:22px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
463
+ xml:space="preserve"><tspan
464
+ y="408.67374"
465
+ x="338.94849"
466
+ id="tspan3046"
467
+ sodipodi:role="line">svg2slides</tspan></text>
468
+ </g>
469
+ </svg>
@@ -0,0 +1,109 @@
1
+ require 'rexml/document'
2
+ require 'getoptlong'
3
+
4
+ class Svg2Slides
5
+
6
+ VERSION = '0.1.0'
7
+
8
+ def process(inputfile)
9
+ doc = REXML::Document.new(File.new(inputfile))
10
+ layers = doc.elements.each('descendant::g[attribute::inkscape:groupmode="layer"]') { |e| e }
11
+ n = layers.size
12
+ while n > 0
13
+ filename = inputfile.sub('.svg', options['--suffix'] + '.svg') % n
14
+ File.open(filename, 'w') do |f|
15
+ say "Writing #{filename} ..."
16
+ doc.write(f)
17
+ layers.last.remove
18
+ layers.pop
19
+ n = n - 1
20
+ end
21
+ end
22
+ end
23
+
24
+ def say(msg)
25
+ puts(msg) unless options['--quiet']
26
+ end
27
+
28
+ OPTIONS = []
29
+ OPTIONS << {
30
+ :name => '--suffix',
31
+ :aliases => [ '-s' ],
32
+ :description => 'Set the suffix for the generated files.',
33
+ :arg => GetoptLong::REQUIRED_ARGUMENT,
34
+ :arg_name => 'SUFFIX',
35
+ :default => '-%03d',
36
+ }
37
+ OPTIONS << {
38
+ :name => '--help',
39
+ :aliases => ['-h'],
40
+ :arg => GetoptLong::NO_ARGUMENT,
41
+ :description => 'Displays help',
42
+ }
43
+ OPTIONS << {
44
+ :name => '--version',
45
+ :aliases => ['-v'],
46
+ :arg => GetoptLong::NO_ARGUMENT,
47
+ :description => 'Display version information and exits.'
48
+ }
49
+ OPTIONS << {
50
+ :name => '--quiet',
51
+ :aliases => ['-q'],
52
+ :arg => GetoptLong::NO_ARGUMENT,
53
+ :description => "Produces no output during execution."
54
+ }
55
+ def options
56
+ @options ||=
57
+ begin
58
+ opts = {}
59
+ OPTIONS.each do |item|
60
+ opts[item[:name]] = item[:default]
61
+ end
62
+ opts
63
+ end
64
+ end
65
+
66
+ def usage
67
+ puts "Usage: svg2slides [OPTIONS] FILE [FILE ...]"
68
+ OPTIONS.each do |opt|
69
+ spec = [opt[:name]] + (opt[:aliases] || [])
70
+ opt_usage =
71
+ case opt[:arg]
72
+ when GetoptLong::NO_ARGUMENT
73
+ spec.join(', ')
74
+ when GetoptLong::REQUIRED_ARGUMENT
75
+ spec.map { |variant| [variant, opt[:arg_name]].join(' ')}.join(', ')
76
+ else
77
+ raise 'unsupported command line option spec: %s' % opt.inspect
78
+ end
79
+ puts
80
+ puts ' ' + opt_usage
81
+ puts
82
+ puts ' ' + opt[:description]
83
+ if opt[:default]
84
+ puts ' ' + '(default: "%s")' % opt[:default]
85
+ end
86
+ end
87
+ end
88
+
89
+ def process_args
90
+ opts = GetoptLong.new(*OPTIONS.map { |item| [item[:name]] + (item[:aliases] || []) + [item[:arg]] })
91
+ opts.each do |opt, arg|
92
+ options[opt] = arg
93
+ end
94
+ if options['--version']
95
+ puts "svg2slides version #{VERSION}"
96
+ exit(0)
97
+ end
98
+ end
99
+
100
+ def run
101
+ process_args
102
+ if ARGV.empty?
103
+ usage
104
+ end
105
+ ARGV.each do |item|
106
+ process(item)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,3 @@
1
+ SVG2SLIDES_INPUT = simple.svg
2
+ include ../data/svg2slides/svg2slides.mk
3
+ all: $(SVG2SLIDES_SLIDES)
@@ -0,0 +1,84 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+ <svg
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
5
+ xmlns:cc="http://creativecommons.org/ns#"
6
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7
+ xmlns:svg="http://www.w3.org/2000/svg"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ width="210mm"
12
+ height="297mm"
13
+ id="svg2"
14
+ sodipodi:version="0.32"
15
+ inkscape:version="0.46"
16
+ sodipodi:docname="simple.svg"
17
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
18
+ <defs
19
+ id="defs4">
20
+ <inkscape:perspective
21
+ sodipodi:type="inkscape:persp3d"
22
+ inkscape:vp_x="0 : 526.18109 : 1"
23
+ inkscape:vp_y="0 : 1000 : 0"
24
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
25
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
26
+ id="perspective10" />
27
+ </defs>
28
+ <sodipodi:namedview
29
+ id="base"
30
+ pagecolor="#ffffff"
31
+ bordercolor="#666666"
32
+ borderopacity="1.0"
33
+ inkscape:pageopacity="0.0"
34
+ inkscape:pageshadow="2"
35
+ inkscape:zoom="0.35"
36
+ inkscape:cx="-47.142857"
37
+ inkscape:cy="520"
38
+ inkscape:document-units="px"
39
+ inkscape:current-layer="layer2"
40
+ showgrid="false"
41
+ inkscape:window-width="1276"
42
+ inkscape:window-height="745"
43
+ inkscape:window-x="0"
44
+ inkscape:window-y="19" />
45
+ <metadata
46
+ id="metadata7">
47
+ <rdf:RDF>
48
+ <cc:Work
49
+ rdf:about="">
50
+ <dc:format>image/svg+xml</dc:format>
51
+ <dc:type
52
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
53
+ </cc:Work>
54
+ </rdf:RDF>
55
+ </metadata>
56
+ <g
57
+ inkscape:label="Layer 1"
58
+ inkscape:groupmode="layer"
59
+ id="layer1">
60
+ <path
61
+ sodipodi:type="arc"
62
+ style="opacity:1;fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
63
+ id="path2383"
64
+ sodipodi:cx="357.14285"
65
+ sodipodi:cy="533.79077"
66
+ sodipodi:rx="234.28572"
67
+ sodipodi:ry="207.14285"
68
+ d="M 591.42857,533.79077 A 234.28572,207.14285 0 1 1 122.85713,533.79077 A 234.28572,207.14285 0 1 1 591.42857,533.79077 z" />
69
+ </g>
70
+ <g
71
+ inkscape:groupmode="layer"
72
+ id="layer2"
73
+ inkscape:label="Layer 2">
74
+ <rect
75
+ style="opacity:1;fill:#e9b96e;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
76
+ id="rect2386"
77
+ width="354.28571"
78
+ height="294.28571"
79
+ x="314.28571"
80
+ y="203.79076"
81
+ rx="17.272532"
82
+ ry="16.6315" />
83
+ </g>
84
+ </svg>
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe 'Makefile snippet' do
4
+
5
+ include CommandRunner
6
+
7
+ it 'builds the slides' do
8
+ make
9
+ files.should include('simple-001.svg')
10
+ files.should include('simple-002.svg')
11
+ end
12
+
13
+ it 'cleans the slides up' do
14
+ original_files = files
15
+ make
16
+ make 'clean'
17
+ files.should == original_files
18
+ end
19
+
20
+ end
@@ -0,0 +1,53 @@
1
+ CURDIR = File.expand_path(Dir.pwd)
2
+ TMPDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'trash'))
3
+
4
+ RSpec.configure do |config|
5
+
6
+ config.before(:all) do
7
+ ENV['PATH'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin')) + ':' + ENV['PATH']
8
+ ENV['RUBYLIB'] =
9
+ File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) +
10
+ (ENV['RUBYLIB'] ? (':' + ENV['RUBYLIB']) : '')
11
+ end
12
+
13
+ config.before(:each) do
14
+ FileUtils.cp_r(File.join(File.dirname(__FILE__), '..', 'sample'), TMPDIR)
15
+ Dir.chdir(TMPDIR)
16
+ end
17
+
18
+ config.after(:each) do
19
+ Dir.chdir(CURDIR)
20
+ FileUtils.rm_rf(TMPDIR)
21
+ end
22
+
23
+ end
24
+
25
+ module CommandRunner
26
+ def make(*args)
27
+ args.unshift('make --quiet')
28
+ run_command(args)
29
+ end
30
+ def svg2slides(*args)
31
+ args.unshift('svg2slides')
32
+ run_command(*args)
33
+ end
34
+ def run_command(*command_line)
35
+ command = command_line.join(' ') + " >tmp.out 2>tmp.err"
36
+ system(command)
37
+ if $?.is_a?(Fixnum)
38
+ @exit_status = $?
39
+ else
40
+ @exit_status = $?.exitstatus
41
+ end
42
+ @stdout = File.readlines('tmp.out').join
43
+ @stderr = File.readlines('tmp.err').join
44
+ FileUtils.rm_f('tmp.out')
45
+ FileUtils.rm_f('tmp.err')
46
+ end
47
+ attr_reader :stdout
48
+ attr_reader :stderr
49
+ attr_reader :exit_status
50
+ def files
51
+ Dir.glob('*')
52
+ end
53
+ end
@@ -0,0 +1,37 @@
1
+ require 'svg_2_slides'
2
+ require 'fileutils'
3
+ require File.join(File.dirname(__FILE__), 'spec_helper')
4
+
5
+ describe Svg2Slides do
6
+
7
+ include CommandRunner
8
+
9
+ it 'displays help message' do
10
+ svg2slides '--help'
11
+ stdout.should match(/--help/)
12
+ end
13
+
14
+ it 'displays version number' do
15
+ svg2slides '--version'
16
+ stdout.should match(Svg2Slides::VERSION)
17
+ end
18
+
19
+ it 'processes a simple drawing' do
20
+ svg2slides 'simple.svg'
21
+ files.should include('simple-001.svg')
22
+ files.should include('simple-002.svg')
23
+ end
24
+
25
+ it 'changes the suffix' do
26
+ svg2slides '--suffix', '_%06d', 'simple.svg'
27
+ files.should include('simple_000001.svg')
28
+ files.should include('simple_000002.svg')
29
+ end
30
+
31
+ it 'can be quiet' do
32
+ svg2slides '--quiet', 'simple.svg'
33
+ files.should include('simple-001.svg')
34
+ stdout.should == ''
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svg2slides
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Antonio Terceiro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ svg2slides takes a single SVG file with separate layers and creates one SVG
15
+ file for each layer. Each generated SVG file contains the corresponding layer and all the layers below it.
16
+ email: terceiro@softwarelivre.org
17
+ executables:
18
+ - svg2slides
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README
23
+ - Rakefile
24
+ - bin/svg2slides
25
+ - data/svg2slides/svg2slides.mk
26
+ - how-it-works.svg
27
+ - lib/svg_2_slides.rb
28
+ - sample/Makefile
29
+ - sample/simple.svg
30
+ - spec/makefile_spec.rb
31
+ - spec/spec_helper.rb
32
+ - spec/svg_2_slides_spec.rb
33
+ homepage:
34
+ licenses: []
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.2.2
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Converts SVG drawings into slides
56
+ test_files: []
57
+ has_rdoc: