prawn-svg 0.15.0.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/README.md +51 -20
- data/lib/prawn/svg/attributes/clip_path.rb +17 -0
- data/lib/prawn/svg/attributes/color.rb +5 -0
- data/lib/prawn/svg/attributes/display.rb +5 -0
- data/lib/prawn/svg/attributes/font.rb +38 -0
- data/lib/prawn/svg/attributes/opacity.rb +15 -0
- data/lib/prawn/svg/attributes/stroke.rb +35 -0
- data/lib/prawn/svg/attributes/transform.rb +50 -0
- data/lib/prawn/svg/attributes.rb +6 -0
- data/lib/prawn/svg/calculators/aspect_ratio.rb +58 -0
- data/lib/prawn/svg/calculators/document_sizing.rb +99 -0
- data/lib/prawn/svg/calculators/pixels.rb +21 -0
- data/lib/prawn/svg/color.rb +197 -12
- data/lib/prawn/svg/css.rb +40 -0
- data/lib/prawn/svg/document.rb +37 -48
- data/lib/prawn/svg/elements/base.rb +238 -0
- data/lib/prawn/svg/elements/circle.rb +25 -0
- data/lib/prawn/svg/elements/container.rb +15 -0
- data/lib/prawn/svg/elements/ellipse.rb +23 -0
- data/lib/prawn/svg/elements/gradient.rb +120 -0
- data/lib/prawn/svg/elements/ignored.rb +5 -0
- data/lib/prawn/svg/elements/image.rb +81 -0
- data/lib/prawn/svg/elements/line.rb +16 -0
- data/lib/prawn/svg/elements/path.rb +405 -0
- data/lib/prawn/svg/elements/polygon.rb +17 -0
- data/lib/prawn/svg/elements/polyline.rb +22 -0
- data/lib/prawn/svg/elements/rect.rb +33 -0
- data/lib/prawn/svg/elements/root.rb +13 -0
- data/lib/prawn/svg/elements/style.rb +10 -0
- data/lib/prawn/svg/elements/text.rb +87 -0
- data/lib/prawn/svg/elements/use.rb +29 -0
- data/lib/prawn/svg/elements.rb +33 -0
- data/lib/prawn/svg/extension.rb +4 -4
- data/lib/prawn/svg/font.rb +10 -92
- data/lib/prawn/svg/font_registry.rb +73 -0
- data/lib/prawn/svg/interface.rb +91 -31
- data/lib/prawn/svg/loaders/data.rb +18 -0
- data/lib/prawn/svg/loaders/file.rb +66 -0
- data/lib/prawn/svg/loaders/web.rb +28 -0
- data/lib/prawn/svg/state.rb +39 -0
- data/lib/prawn/svg/ttf.rb +61 -0
- data/lib/prawn/svg/url_loader.rb +46 -0
- data/lib/prawn/svg/version.rb +2 -2
- data/lib/prawn-svg.rb +20 -6
- data/prawn-svg.gemspec +8 -5
- data/spec/integration_spec.rb +141 -0
- data/spec/prawn/svg/attributes/font_spec.rb +52 -0
- data/spec/prawn/svg/attributes/transform_spec.rb +56 -0
- data/spec/prawn/svg/calculators/aspect_ratio_spec.rb +95 -0
- data/spec/prawn/svg/calculators/document_sizing_spec.rb +128 -0
- data/spec/prawn/svg/color_spec.rb +43 -8
- data/spec/prawn/svg/css_spec.rb +24 -0
- data/spec/prawn/svg/document_spec.rb +48 -19
- data/spec/prawn/svg/elements/base_spec.rb +147 -0
- data/spec/prawn/svg/elements/gradient_spec.rb +61 -0
- data/spec/prawn/svg/elements/path_spec.rb +123 -0
- data/spec/prawn/svg/elements/style_spec.rb +23 -0
- data/spec/prawn/svg/elements/text_spec.rb +61 -0
- data/spec/prawn/svg/font_registry_spec.rb +54 -0
- data/spec/prawn/svg/font_spec.rb +1 -28
- data/spec/prawn/svg/interface_spec.rb +94 -0
- data/spec/prawn/svg/loaders/data_spec.rb +55 -0
- data/spec/prawn/svg/loaders/file_spec.rb +84 -0
- data/spec/prawn/svg/loaders/web_spec.rb +37 -0
- data/spec/prawn/svg/ttf_spec.rb +32 -0
- data/spec/prawn/svg/url_loader_spec.rb +112 -0
- data/spec/sample_images/mushroom-long.jpg +0 -0
- data/spec/sample_images/mushroom-wide.jpg +0 -0
- data/spec/sample_svg/cap_styles.svg +13 -0
- data/spec/sample_svg/display_none.svg +13 -0
- data/spec/sample_svg/gistfile1.svg +36 -0
- data/spec/sample_svg/gradients.svg +40 -0
- data/spec/sample_svg/hidden_paths.svg +6 -0
- data/spec/sample_svg/image01.svg +31 -31
- data/spec/sample_svg/image03.svg +30 -0
- data/spec/sample_svg/negminy.svg +25 -0
- data/spec/sample_svg/no_width_or_height.svg +4 -0
- data/spec/sample_svg/path.svg +5 -0
- data/spec/sample_svg/pie_piece.svg +7 -0
- data/spec/sample_svg/preserve-space.svg +19 -0
- data/spec/sample_svg/rect02.svg +8 -11
- data/spec/sample_svg/tspan03-cc.svg +21 -0
- data/spec/sample_svg/viewbox.svg +4 -0
- data/spec/sample_svg/viewport.svg +23 -0
- data/spec/sample_ttf/OpenSans-SemiboldItalic.ttf +0 -0
- data/spec/spec_helper.rb +24 -2
- metadata +150 -36
- data/lib/prawn/svg/element.rb +0 -237
- data/lib/prawn/svg/parser/image.rb +0 -134
- data/lib/prawn/svg/parser/path.rb +0 -374
- data/lib/prawn/svg/parser/text.rb +0 -66
- data/lib/prawn/svg/parser.rb +0 -233
- data/spec/lib/parser_spec.rb +0 -55
- data/spec/lib/path_spec.rb +0 -54
- data/spec/lib/svg_spec.rb +0 -47
- data/spec/prawn/svg/element_spec.rb +0 -36
- data/spec/prawn/svg/parser/text_spec.rb +0 -4
@@ -0,0 +1,40 @@
|
|
1
|
+
<svg width="240" height="240" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<defs>
|
3
|
+
<style type="text/css"><![CDATA[
|
4
|
+
#rect1 { fill: url(#Gradient1); }
|
5
|
+
.stop1 { stop-color: red; }
|
6
|
+
.stop2 { stop-color: black; stop-opacity: 0; }
|
7
|
+
.stop3 { stop-color: blue; }
|
8
|
+
]]></style>
|
9
|
+
<linearGradient id="Gradient1">
|
10
|
+
<stop class="stop1" offset="0%"/>
|
11
|
+
<stop class="stop2" offset="50%"/>
|
12
|
+
<stop class="stop3" offset="100%"/>
|
13
|
+
</linearGradient>
|
14
|
+
<linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
|
15
|
+
<stop offset="25%" stop-color="red"/>
|
16
|
+
<stop offset="50%" stop-color="black" stop-opacity="0"/>
|
17
|
+
<stop offset="75%" stop-color="blue"/>
|
18
|
+
</linearGradient>
|
19
|
+
<linearGradient id="Gradient3" x1="0" x2="1" y1="0" y2="1">
|
20
|
+
<stop offset="0%" stop-color="red"/>
|
21
|
+
<stop offset="30%" stop-color="yellow"/>
|
22
|
+
<stop offset="60%" stop-color="orange"/>
|
23
|
+
<stop offset="100%" stop-color="blue"/>
|
24
|
+
</linearGradient>
|
25
|
+
<linearGradient id="userspace" gradientUnits="userSpaceOnUse" x1="160" y1="90" x2="220" y2="90">
|
26
|
+
<stop offset="0" stop-color="red"/>
|
27
|
+
<stop offset="1" stop-color="blue"/>
|
28
|
+
</linearGradient>
|
29
|
+
</defs>
|
30
|
+
|
31
|
+
<rect id="rect1" x="10" y="10" rx="15" ry="15" width="50" height="100" stroke="black"/>
|
32
|
+
<rect x="10" y="120" rx="15" ry="15" width="50" height="100" fill="url(#Gradient2)" stroke="black"/>
|
33
|
+
<circle cx="110" cy="40" r="30" stroke="black" fill="url(#Gradient3)"/>
|
34
|
+
<ellipse cx="110" cy="100" rx="30" ry="20" stroke="black" fill="url(#Gradient1)"/>
|
35
|
+
<line x1="65" y1="120" x2="200" y2="200" stroke="url(#Gradient3)" stroke-width="5"/>
|
36
|
+
<path d="M80,140l0,50l30,20l0-40z" stroke="url(#Gradient3)" fill="url(#Gradient1)" stroke-width="3"/>
|
37
|
+
<polygon points="150,30 170,80 190,55 200,10" fill="url(#Gradient1)"/>
|
38
|
+
<rect x="150" y="90" width="80" height="30" fill="url(#userspace)" stroke="black"/>
|
39
|
+
<polyline points="150,130 170,170 190,155 200,110" stroke="url(#Gradient1)" stroke-width="3" fill="none"/>
|
40
|
+
</svg>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<svg style="fill: none;">
|
2
|
+
<g class="x axis" transform="translate(0,227.9359)">
|
3
|
+
<path class="domain" d="M0,0V0H470V0" style="fill: none; stroke: none;"></path>
|
4
|
+
<path d="M 44.82625 0 L 44.82625 -3 L 94 -3 L 94 0" class="cantilever" style="stroke: black; fill: none;"></path>
|
5
|
+
</g>
|
6
|
+
</svg>
|
data/spec/sample_svg/image01.svg
CHANGED
@@ -18,113 +18,113 @@
|
|
18
18
|
<text y="25" font-size="12pt">wide image, aspect ratio meet</text>
|
19
19
|
|
20
20
|
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
21
|
-
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="
|
21
|
+
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
22
22
|
|
23
23
|
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
24
|
-
<image y="200" width="150" height="100" xlink:href="
|
24
|
+
<image y="200" width="150" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
25
25
|
|
26
26
|
<rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
27
|
-
<image y="350" width="100" height="150" xlink:href="
|
27
|
+
<image y="350" width="100" height="150" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
28
28
|
|
29
29
|
<rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
30
|
-
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="
|
30
|
+
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
31
31
|
|
32
32
|
<rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
33
|
-
<image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="
|
33
|
+
<image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
34
34
|
|
35
35
|
<rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
36
|
-
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="
|
36
|
+
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
37
37
|
|
38
38
|
<rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
39
|
-
<image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="
|
39
|
+
<image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
40
40
|
</g>
|
41
41
|
|
42
42
|
<g transform="translate(250 0)">
|
43
43
|
<text y="25" font-size="12pt">wide image, aspect ratio slice</text>
|
44
44
|
|
45
45
|
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
46
|
-
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="
|
46
|
+
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
47
47
|
|
48
48
|
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
49
|
-
<image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="
|
49
|
+
<image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
50
50
|
|
51
51
|
<rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
52
|
-
<image y="350" width="100" height="150" preserveAspectRatio="xMidYMid slice" xlink:href="
|
52
|
+
<image y="350" width="100" height="150" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
53
53
|
|
54
54
|
<rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
55
|
-
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="
|
55
|
+
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
56
56
|
|
57
57
|
<rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
58
|
-
<image y="700" width="100" height="150" preserveAspectRatio="xMinYMin slice" xlink:href="
|
58
|
+
<image y="700" width="100" height="150" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
59
59
|
|
60
60
|
<rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
61
|
-
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="
|
61
|
+
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
62
62
|
|
63
63
|
<rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
64
|
-
<image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax slice" xlink:href="
|
64
|
+
<image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
|
65
65
|
</g>
|
66
66
|
|
67
67
|
<g transform="translate(450 0)">
|
68
68
|
<text y="25" font-size="12pt">long image, aspect ratio meet</text>
|
69
69
|
|
70
70
|
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
71
|
-
<image y="50" width="100" height="100" xlink:href="
|
71
|
+
<image y="50" width="100" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
72
72
|
|
73
73
|
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
74
|
-
<image y="200" width="150" height="100" xlink:href="
|
74
|
+
<image y="200" width="150" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
75
75
|
|
76
76
|
<rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
77
|
-
<image y="350" width="100" height="200" xlink:href="
|
77
|
+
<image y="350" width="100" height="200" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
78
78
|
|
79
79
|
<rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
80
|
-
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="
|
80
|
+
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
81
81
|
|
82
82
|
<rect y="700" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
83
|
-
<image y="700" width="100" height="200" preserveAspectRatio="xMinYMin" xlink:href="
|
83
|
+
<image y="700" width="100" height="200" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
84
84
|
|
85
85
|
<rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
86
|
-
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="
|
86
|
+
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
87
87
|
|
88
88
|
<rect y="1050" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
89
|
-
<image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax" xlink:href="
|
89
|
+
<image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
90
90
|
</g>
|
91
91
|
|
92
92
|
<g transform="translate(650 0)">
|
93
93
|
<text y="25" font-size="12pt">long image, aspect ratio slice</text>
|
94
94
|
|
95
95
|
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
96
|
-
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="
|
96
|
+
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
97
97
|
|
98
98
|
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
99
|
-
<image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="
|
99
|
+
<image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
100
100
|
|
101
101
|
<rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
102
|
-
<image y="350" width="100" height="200" preserveAspectRatio="xMidYMid slice" xlink:href="
|
102
|
+
<image y="350" width="100" height="200" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
103
103
|
|
104
104
|
<rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
105
|
-
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="
|
105
|
+
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
106
106
|
|
107
107
|
<rect y="700" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
108
|
-
<image y="700" width="100" height="200" preserveAspectRatio="xMinYMin slice" xlink:href="
|
108
|
+
<image y="700" width="100" height="200" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
109
109
|
|
110
110
|
<rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
111
|
-
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="
|
111
|
+
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
112
112
|
|
113
113
|
<rect y="1050" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
114
|
-
<image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax slice" xlink:href="
|
114
|
+
<image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
115
115
|
</g>
|
116
116
|
|
117
117
|
<g transform="translate(850 0)">
|
118
118
|
<text y="25" font-size="12pt">aspect ratio preservation disabled</text>
|
119
119
|
|
120
120
|
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
121
|
-
<image y="50" width="100" height="100" preserveAspectRatio="none" xlink:href="
|
121
|
+
<image y="50" width="100" height="100" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
122
122
|
|
123
123
|
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
124
|
-
<image y="200" width="150" height="100" preserveAspectRatio="none" xlink:href="
|
124
|
+
<image y="200" width="150" height="100" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
125
125
|
|
126
126
|
<rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
|
127
|
-
<image y="350" width="100" height="200" preserveAspectRatio="none" xlink:href="
|
127
|
+
<image y="350" width="100" height="200" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
|
128
128
|
</g>
|
129
129
|
|
130
130
|
</svg>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3
|
+
<svg width="210mm" height="297mm" viewBox="0 0 1050 1485"
|
4
|
+
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
|
5
|
+
|
6
|
+
<g transform="translate(50 0)">
|
7
|
+
<text y="25" font-size="12pt">wide image, aspect ratio meet</text>
|
8
|
+
|
9
|
+
<rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
10
|
+
<image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
11
|
+
|
12
|
+
<rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
13
|
+
<image y="200" width="150" height="100" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
14
|
+
|
15
|
+
<rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
16
|
+
<image y="350" width="100" height="150" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
17
|
+
|
18
|
+
<rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
19
|
+
<image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
20
|
+
|
21
|
+
<rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
22
|
+
<image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
23
|
+
|
24
|
+
<rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
|
25
|
+
<image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
26
|
+
|
27
|
+
<rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
|
28
|
+
<image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="sample_images/mushroom-wide.jpg"></image>
|
29
|
+
</g>
|
30
|
+
</svg>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 -1329 4012.5722934428577 1964.1614245832113" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<defs id="MathJax_SVG_glyphs">
|
3
|
+
<path id="STIXWEBSIZE1-221A" stroke-width="10" d="M1089 1552l-562 -1847h-42l-231 751c-14 46 -30 68 -62 68c-19 0 -44 -8 -68 -27l-12 20l164 126h25l227 -737h4l500 1646h57Z"/>
|
4
|
+
<path id="STIXWEBMAINI-78" stroke-width="10" d="M243 355l12 -57c70 107 107 143 151 143c24 0 41 -15 41 -37c0 -21 -14 -36 -34 -36c-19 0 -28 17 -52 17c-18 0 -54 -44 -98 -121c0 -7 2 -21 8 -45l32 -134c7 -28 16 -41 30 -41c13 0 24 10 47 40c9 12 13 18 21 28l15 -9c-58 -90 -84 -114 -122 -114 c-32 0 -47 18 -59 68l-29 119l-88 -119c-44 -59 -64 -68 -95 -68s-50 16 -50 42c0 20 14 36 34 36c9 0 19 -4 32 -11c10 -6 20 -9 26 -9c11 0 30 19 51 49l82 116l-28 124c-14 60 -21 68 -46 68c-8 0 -20 -2 -39 -7l-18 -5l-3 16l11 4c61 22 94 29 117 29 c25 0 37 -18 51 -86Z"/>
|
5
|
+
<path id="STIXWEBMAIN-32" stroke-width="10" d="M474 137l-54 -137h-391v12l178 189c94 99 130 175 130 260c0 91 -54 141 -139 141c-72 0 -107 -32 -147 -130l-21 5c21 117 85 199 208 199c113 0 185 -77 185 -176c0 -79 -39 -154 -128 -248l-165 -176h234c42 0 63 11 96 67Z"/>
|
6
|
+
<path id="STIXWEBMAIN-2B" stroke-width="10" d="M636 220h-261v-261h-66v261h-261v66h261v261h66v-261h261v-66Z"/>
|
7
|
+
<path id="STIXWEBMAINI-79" stroke-width="10" d="M243 186l21 -110c85 141 122 213 122 257c0 14 -7 20 -26 32c-20 13 -26 23 -26 39c0 22 17 37 40 37c30 0 52 -25 52 -55c0 -57 -48 -167 -131 -305c-104 -172 -211 -287 -268 -287c-30 0 -51 17 -51 43c0 22 17 40 39 40c35 0 35 -28 61 -28c13 0 25 8 48 33 c18 19 63 78 71 91c6 12 10 24 10 35c0 40 -55 264 -82 332c-19 49 -37 64 -77 64c-11 0 -20 -1 -31 -4v17c11 2 22 4 32 6c20 4 53 10 107 18h4c15 0 68 -166 85 -255Z"/>
|
8
|
+
</defs>
|
9
|
+
<g transform="matrix(1 0 0 1 0 0)">
|
10
|
+
<rect x="0" y="-1329" width="4012" height="1964" stroke="green" fill="none" stroke-width="5" />
|
11
|
+
<g stroke="black" fill="black" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">
|
12
|
+
<use href="#STIXWEBSIZE1-221A" x="0" y="-312" xlink:href="#STIXWEBSIZE1-221A"/>
|
13
|
+
<rect stroke="none" width="2950" height="60" x="1062" y="1190"/>
|
14
|
+
<g transform="translate(1062,0)">
|
15
|
+
<use href="#STIXWEBMAINI-78" xlink:href="#STIXWEBMAINI-78"/>
|
16
|
+
<use transform="scale(0.7071067811865476)" href="#STIXWEBMAIN-32" x="640" y="583" xlink:href="#STIXWEBMAIN-32"/>
|
17
|
+
<use href="#STIXWEBMAIN-2B" x="1132" y="0" xlink:href="#STIXWEBMAIN-2B"/>
|
18
|
+
<g transform="translate(2044,0)">
|
19
|
+
<use href="#STIXWEBMAINI-79" xlink:href="#STIXWEBMAINI-79"/>
|
20
|
+
<use transform="scale(0.7071067811865476)" href="#STIXWEBMAIN-32" x="634" y="583" xlink:href="#STIXWEBMAIN-32"/>
|
21
|
+
</g>
|
22
|
+
</g>
|
23
|
+
</g>
|
24
|
+
</g>
|
25
|
+
</svg>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1100" height="400">
|
2
|
+
<rect x="100" y="100" width="900" height="300" fill="none" stroke="blue" stroke-width="2" />
|
3
|
+
|
4
|
+
<path d="M200 200 L800 300 L800 200" stroke="green" stroke-width="10" fill="red" />
|
5
|
+
</svg>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" style="font-family:'lucida grande', 'lucida sans unicode', arial, helvetica, sans-serif;font-size:12px;" xmlns="http://www.w3.org/2000/svg" width="850" height="300">
|
2
|
+
<g transform="translate(10,10) scale(1 1)">
|
3
|
+
<path fill="#009ACB" d="M 414.97698492798247 39.00000234377684 A 113 113 0 1 1 311.39206002954353
|
4
|
+
197.10426559737175 L 415 152 A 0 0 0 1 0 415 152 Z" stroke="#FFFFFF" stroke-width="1" stroke-linejoin="round"
|
5
|
+
transform="translate(0,0)"></path>
|
6
|
+
</g>
|
7
|
+
</svg>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="500" height="500">
|
3
|
+
<text x="0" y="40" xml:space="preserve" font-size="30" letter-spacing="5">Text (Far away text)</text>
|
4
|
+
<text x="0" y="80" font-size="30" letter-spacing="5">Text (Close text)</text>
|
5
|
+
<text x="0" y="120" xml:space="preserve" font-size="30" letter-spacing="5">
|
6
|
+
Text
|
7
|
+
With
|
8
|
+
Newlines
|
9
|
+
And
|
10
|
+
Preserve
|
11
|
+
</text>
|
12
|
+
<text x="0" y="160" font-size="30" letter-spacing="5">
|
13
|
+
Text
|
14
|
+
With
|
15
|
+
Newlines
|
16
|
+
No
|
17
|
+
Preserve
|
18
|
+
</text>
|
19
|
+
</svg>
|
data/spec/sample_svg/rect02.svg
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
<?xml version="1.0" standalone="no"?>
|
2
|
-
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
-
|
4
|
-
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
|
5
|
-
xmlns="http://www.w3.org/2000/svg" version="1.1">
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3
|
+
<svg width="12cm" height="8cm" viewBox="0 0 1200 800" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
6
4
|
<desc>Example rect02 - rounded rectangles</desc>
|
7
|
-
|
8
|
-
<rect x="1" y="1" width="1198" height="
|
9
|
-
|
10
|
-
<rect x="100" y="
|
11
|
-
|
5
|
+
|
6
|
+
<rect x="1" y="1" width="1198" height="798" fill="none" stroke="blue" stroke-width="2"/>
|
7
|
+
<rect x="100" y="100" width="400" height="200" rx="50" fill="green" />
|
8
|
+
<rect x="100" y="500" width="400" height="200" rx="100" ry="10" fill="orange" />
|
9
|
+
|
12
10
|
<g transform="translate(700 210) rotate(-30)">
|
13
|
-
<rect x="0" y="0" width="400" height="200" rx="50"
|
14
|
-
fill="none" stroke="purple" stroke-width="30" />
|
11
|
+
<rect x="0" y="0" width="400" height="200" rx="50" fill="none" stroke="purple" stroke-width="30" />
|
15
12
|
</g>
|
16
13
|
</svg>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
|
5
|
+
xmlns="http://www.w3.org/2000/svg" version="1.1">
|
6
|
+
<desc>Example tspan03 - using tspan's x and y attributes
|
7
|
+
for multiline text and precise glyph positioning</desc>
|
8
|
+
<g font-family="Verdana" font-size="45" style="color: rgb(255,164,0)">
|
9
|
+
<text style="fill: currentColor">
|
10
|
+
<tspan x="300 350 400 450 500 550 600 650" y="100">
|
11
|
+
Cute and
|
12
|
+
</tspan>
|
13
|
+
<tspan x="375 425 475 525 575" y="200">
|
14
|
+
fuzzy
|
15
|
+
</tspan>
|
16
|
+
</text>
|
17
|
+
</g>
|
18
|
+
<!-- Show outline of canvas using 'rect' element -->
|
19
|
+
<rect x="1" y="1" width="998" height="298"
|
20
|
+
fill="none" stroke="blue" stroke-width="2" />
|
21
|
+
</svg>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300" viewBox="-100 -100 100 100" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<rect x="-98" y="-98" width="96" height="96" fill="blue" stroke="red" />
|
3
|
+
<line x1="-1000" y1="-1000" x2="1000" y2="1000" stroke="green" />
|
4
|
+
</svg>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg width="100px" height="200px" version="1.1"
|
5
|
+
viewBox="0 0 1500 1000" preserveAspectRatio="none"
|
6
|
+
xmlns="http://www.w3.org/2000/svg">
|
7
|
+
<desc>Example ViewBox - uses the viewBox
|
8
|
+
attribute to automatically create an initial user coordinate
|
9
|
+
system which causes the graphic to scale to fit into the
|
10
|
+
viewport no matter what size the viewport is.</desc>
|
11
|
+
<!-- This rectangle goes from (0,0) to (1500,1000) in user space.
|
12
|
+
Because of the viewBox attribute above,
|
13
|
+
the rectangle will end up filling the entire area
|
14
|
+
reserved for the SVG content. -->
|
15
|
+
<rect x="0" y="0" width="1500" height="1000"
|
16
|
+
fill="yellow" stroke="blue" stroke-width="12" />
|
17
|
+
<!-- A large, red triangle -->
|
18
|
+
<path fill="red" d="M 750,100 L 250,900 L 1250,900 z"/>
|
19
|
+
<!-- A text string that spans most of the viewport -->
|
20
|
+
<text x="100" y="600" font-size="200" font-family="Verdana" >
|
21
|
+
Stretch to fit
|
22
|
+
</text>
|
23
|
+
</svg>
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,29 @@ Bundler.require(:default, :development)
|
|
5
5
|
# in ./support/ and its subdirectories.
|
6
6
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
7
7
|
|
8
|
-
|
8
|
+
module Support
|
9
|
+
def flatten_calls(calls)
|
10
|
+
[].tap do |flattened_calls|
|
11
|
+
add = -> (calls) do
|
12
|
+
calls.each do |call|
|
13
|
+
flattened_calls << call[0..1]
|
14
|
+
add.call call[2]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
add.call element.base_calls
|
19
|
+
end
|
20
|
+
end
|
9
21
|
end
|
10
22
|
|
11
|
-
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.mock_with :rspec do |c|
|
25
|
+
c.syntax = [:should, :expect]
|
26
|
+
end
|
27
|
+
|
28
|
+
config.expect_with :rspec do |c|
|
29
|
+
c.syntax = [:should, :expect]
|
30
|
+
end
|
31
|
+
|
32
|
+
config.include Support
|
33
|
+
end
|