ruby_svg_light 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.md ADDED
@@ -0,0 +1,31 @@
1
+ HISTORY/Changelog
2
+ =================
3
+
4
+ 0.0.3
5
+ -----
6
+
7
+ Text placemnet options
8
+ 1) Added :text_horizontal_centre=>true
9
+ 2) Added :text_vertical_centre=>true
10
+ 3) Added :text_centre
11
+
12
+ Added Specs for basic shapes and text allingment
13
+
14
+ 0.0.2
15
+ -----
16
+
17
+ Added Rakefile
18
+ Added support for ellipse
19
+
20
+ 0.0.1
21
+ -----
22
+
23
+ Initial build with:
24
+ circle
25
+ rectangle
26
+ line
27
+ text
28
+
29
+ Retrival of svg is via to_file or to_s
30
+
31
+
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ RubySVGLight
2
+ ============
3
+
4
+ Install
5
+ -------
6
+
7
+ gem install ruby_svg_light
8
+
9
+ Usage
10
+ -----
11
+
12
+ Create a new document (canvas) with RubySVGLight::Document.new then add the shapes you require to it. Finally use to_file to generate the file or call to_s to return the string of the SVG (useful for webapps).
13
+
14
+ Shapes available (x and y starting coordinates and cx and cy center of circle and ellipse)
15
+
16
+ circle(cx, cy, radius)
17
+ rectangle(x, y, width, height)
18
+ line(x, y, width, height)
19
+ text(x, y, 'text')
20
+ ellipse(cx, cy, horizontal_radius, vertical_radius)
21
+
22
+ All can take a options hash as a final option. Supported options are:
23
+
24
+ options[:stroke]
25
+ options[:stroke_width]
26
+ options[:fill]
27
+ options[:font_size]
28
+
29
+ Global options can also be set by passing to new or options, as seen in second example.
30
+
31
+
32
+ Examples
33
+ --------
34
+
35
+ require 'ruby_svg_light'
36
+ a = RubySVGLight::Document.new()
37
+ a.circle(20,10,10)
38
+ a.to_file('test.svg')
39
+
40
+ Second Example, From the Examples directory
41
+
42
+ require 'ruby_svg_light'
43
+ canvas = RubySVGLight::Document.new
44
+ canvas.circle(40,40,20)
45
+ canvas.rectangle(80,20,40,40)
46
+ canvas.line(20,80,100,0)
47
+ canvas.line(20,105,100,0)
48
+
49
+ #Set Global Options
50
+ options = {:font_size=>'12px'}
51
+ canvas.options(options)
52
+ canvas.text(20,100, 'HelloWorld!')
53
+
54
+ #Set Local Options
55
+ canvas.text(20,130, 'HelloWorld!', {:font_size=>'18px'})
56
+
57
+ canvas.to_file('shapes.svg')
58
+
59
+ Text placment options
60
+
61
+ canvas.text(0,20, 'HelloWorld!', {:text_horizontal_centre=>true})
62
+ canvas.text(0,0, 'HelloWorld!', {:text_vertical_centre=>true})
63
+ # Centre Horizontally and Vertically
64
+ canvas.text(0,40, 'HelloWorld!', {:text_centre=>true})
65
+
66
+
67
+
68
+ TODO
69
+ ----
70
+
71
+ Add support for path
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ file_list = FileList['spec/*_spec.rb']
4
+
5
+ RSpec::Core::RakeTask.new('spec') do |t|
6
+ t.pattern = file_list
7
+ t.rspec_opts = ["--colour", "--format progress", "-p"]
8
+ end
9
+
10
+ desc 'Default: run specs.'
11
+ task :default => 'spec'
@@ -0,0 +1,71 @@
1
+
2
+ test = false #require 'ruby_svg_light'
3
+ if not test
4
+ require '../lib/ruby_svg_light'
5
+ end
6
+
7
+ def drawbox_with_crosshairs(canvas, x, y, width, height)
8
+ hheight = height/2
9
+ hwidth = width/2
10
+ pointer = 20
11
+ hpointer = pointer/2
12
+
13
+ canvas.rectangle(x,y,width,height)
14
+ canvas.line(x+hwidth-hpointer,y+hheight,pointer,0)
15
+ canvas.line(x+hwidth,y+hheight-hpointer,0,pointer)
16
+ end
17
+
18
+ canvas = RubySVGLight::Document.new
19
+ width,height = 100,40
20
+ x,y = 20,20
21
+ drawbox_with_crosshairs(canvas, x ,y, width, height)
22
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px'})
23
+ # Demo of expected positioning
24
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
25
+ canvas.rectangle(x+width+20+(width/2),y,width/2,height/2, {:fill=>'green'})
26
+
27
+
28
+ x,y = 20,4*20
29
+ drawbox_with_crosshairs(canvas, x ,y, 100, 40)
30
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px',:text_horizontal_top=>true})
31
+ # Demo of expected positioning
32
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
33
+ canvas.rectangle(x+width+20+(width/2),y,width/2,height/2, {:fill=>'green'})
34
+
35
+
36
+ x,y = 20,7*20
37
+ drawbox_with_crosshairs(canvas, x ,y, 100, 40)
38
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px',:text_horizontal_middle=>true})
39
+ # Demo of expected positioning
40
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
41
+ canvas.rectangle(x+width+20+(width/4),y,width/2,height/2, {:fill=>'green'})
42
+
43
+
44
+ x,y = 20,10*20
45
+ drawbox_with_crosshairs(canvas, x ,y, 100, 40)
46
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px',:text_horizontal_bottom=>true})
47
+ # Demo of expected positioning
48
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
49
+ canvas.rectangle(x+width+20+(width/2),y,width/2,height/2, {:fill=>'green'})
50
+
51
+
52
+
53
+
54
+
55
+ x,y = 20,13*20
56
+ drawbox_with_crosshairs(canvas, x ,y, 100, 40)
57
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px',:text_vertical_middle=>true})
58
+ # Demo of expected positioning
59
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
60
+ canvas.rectangle(x+width+20+(width/2),y+(height/4),width/2,height/2, {:fill=>'green'})
61
+
62
+
63
+ x,y = 20,16*20
64
+ drawbox_with_crosshairs(canvas, x ,y, 100, 40)
65
+ canvas.text( x+(100/2), y+(40/2), 'HelloWorld', {:font_size=>'12px',:text_horizontal_middle=>true, :text_vertical_middle=>true})
66
+ # Demo of expected positioning
67
+ canvas.rectangle(x+width+20,y,width,height, {:fill=>'white'})
68
+ canvas.rectangle(x+width+20+(width/4),y+(height/4),width/2,height/2, {:fill=>'green'})
69
+
70
+
71
+ canvas.to_file('text_position.svg')
@@ -0,0 +1,285 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+
4
+ <svg
5
+ width="100%"
6
+ height="100%"
7
+ version="1.1"
8
+ xmlns="http://www.w3.org/2000/svg">
9
+
10
+ <rect
11
+ x="20" y="20"
12
+ width="100" height="40"
13
+ fill="white"
14
+ stroke="#000000"
15
+ stroke-width="1"
16
+ />
17
+
18
+ <line
19
+ x1="60" y1="40"
20
+ x2="80" y2="40"
21
+ stroke="#000000"
22
+ stroke-width="1"
23
+ />
24
+
25
+ <line
26
+ x1="70" y1="30"
27
+ x2="70" y2="50"
28
+ stroke="#000000"
29
+ stroke-width="1"
30
+ />
31
+
32
+ <text
33
+ x="70" y="40"
34
+ font-size="12px"
35
+ fill="#000000"
36
+ font-family="Sans"
37
+ >HelloWorld
38
+ </text>
39
+ <rect
40
+ x="140" y="20"
41
+ width="100" height="40"
42
+ fill="white"
43
+ stroke="#000000"
44
+ stroke-width="1"
45
+ />
46
+
47
+ <rect
48
+ x="190" y="20"
49
+ width="50" height="20"
50
+ fill="green"
51
+ stroke="#000000"
52
+ stroke-width="1"
53
+ />
54
+
55
+ <rect
56
+ x="20" y="80"
57
+ width="100" height="40"
58
+ fill="white"
59
+ stroke="#000000"
60
+ stroke-width="1"
61
+ />
62
+
63
+ <line
64
+ x1="60" y1="100"
65
+ x2="80" y2="100"
66
+ stroke="#000000"
67
+ stroke-width="1"
68
+ />
69
+
70
+ <line
71
+ x1="70" y1="90"
72
+ x2="70" y2="110"
73
+ stroke="#000000"
74
+ stroke-width="1"
75
+ />
76
+
77
+ <text
78
+ x="70" y="100"
79
+ style="text-anchor: top; "
80
+ font-size="12px"
81
+ fill="#000000"
82
+ font-family="Sans"
83
+ >HelloWorld
84
+ </text>
85
+ <rect
86
+ x="140" y="80"
87
+ width="100" height="40"
88
+ fill="white"
89
+ stroke="#000000"
90
+ stroke-width="1"
91
+ />
92
+
93
+ <rect
94
+ x="190" y="80"
95
+ width="50" height="20"
96
+ fill="green"
97
+ stroke="#000000"
98
+ stroke-width="1"
99
+ />
100
+
101
+ <rect
102
+ x="20" y="140"
103
+ width="100" height="40"
104
+ fill="white"
105
+ stroke="#000000"
106
+ stroke-width="1"
107
+ />
108
+
109
+ <line
110
+ x1="60" y1="160"
111
+ x2="80" y2="160"
112
+ stroke="#000000"
113
+ stroke-width="1"
114
+ />
115
+
116
+ <line
117
+ x1="70" y1="150"
118
+ x2="70" y2="170"
119
+ stroke="#000000"
120
+ stroke-width="1"
121
+ />
122
+
123
+ <text
124
+ x="70" y="160"
125
+ style="text-anchor: middle; "
126
+ font-size="12px"
127
+ fill="#000000"
128
+ font-family="Sans"
129
+ >HelloWorld
130
+ </text>
131
+ <rect
132
+ x="140" y="140"
133
+ width="100" height="40"
134
+ fill="white"
135
+ stroke="#000000"
136
+ stroke-width="1"
137
+ />
138
+
139
+ <rect
140
+ x="165" y="140"
141
+ width="50" height="20"
142
+ fill="green"
143
+ stroke="#000000"
144
+ stroke-width="1"
145
+ />
146
+
147
+ <rect
148
+ x="20" y="200"
149
+ width="100" height="40"
150
+ fill="white"
151
+ stroke="#000000"
152
+ stroke-width="1"
153
+ />
154
+
155
+ <line
156
+ x1="60" y1="220"
157
+ x2="80" y2="220"
158
+ stroke="#000000"
159
+ stroke-width="1"
160
+ />
161
+
162
+ <line
163
+ x1="70" y1="210"
164
+ x2="70" y2="230"
165
+ stroke="#000000"
166
+ stroke-width="1"
167
+ />
168
+
169
+ <text
170
+ x="70" y="220"
171
+ style="text-anchor: bottom; "
172
+ font-size="12px"
173
+ fill="#000000"
174
+ font-family="Sans"
175
+ >HelloWorld
176
+ </text>
177
+ <rect
178
+ x="140" y="200"
179
+ width="100" height="40"
180
+ fill="white"
181
+ stroke="#000000"
182
+ stroke-width="1"
183
+ />
184
+
185
+ <rect
186
+ x="190" y="200"
187
+ width="50" height="20"
188
+ fill="green"
189
+ stroke="#000000"
190
+ stroke-width="1"
191
+ />
192
+
193
+ <rect
194
+ x="20" y="260"
195
+ width="100" height="40"
196
+ fill="white"
197
+ stroke="#000000"
198
+ stroke-width="1"
199
+ />
200
+
201
+ <line
202
+ x1="60" y1="280"
203
+ x2="80" y2="280"
204
+ stroke="#000000"
205
+ stroke-width="1"
206
+ />
207
+
208
+ <line
209
+ x1="70" y1="270"
210
+ x2="70" y2="290"
211
+ stroke="#000000"
212
+ stroke-width="1"
213
+ />
214
+
215
+ <text
216
+ x="70" y="280"
217
+ style="dominant-baseline: central; "
218
+ font-size="12px"
219
+ fill="#000000"
220
+ font-family="Sans"
221
+ >HelloWorld
222
+ </text>
223
+ <rect
224
+ x="140" y="260"
225
+ width="100" height="40"
226
+ fill="white"
227
+ stroke="#000000"
228
+ stroke-width="1"
229
+ />
230
+
231
+ <rect
232
+ x="190" y="270"
233
+ width="50" height="20"
234
+ fill="green"
235
+ stroke="#000000"
236
+ stroke-width="1"
237
+ />
238
+
239
+ <rect
240
+ x="20" y="320"
241
+ width="100" height="40"
242
+ fill="white"
243
+ stroke="#000000"
244
+ stroke-width="1"
245
+ />
246
+
247
+ <line
248
+ x1="60" y1="340"
249
+ x2="80" y2="340"
250
+ stroke="#000000"
251
+ stroke-width="1"
252
+ />
253
+
254
+ <line
255
+ x1="70" y1="330"
256
+ x2="70" y2="350"
257
+ stroke="#000000"
258
+ stroke-width="1"
259
+ />
260
+
261
+ <text
262
+ x="70" y="340"
263
+ style="dominant-baseline: central; text-anchor: middle; "
264
+ font-size="12px"
265
+ fill="#000000"
266
+ font-family="Sans"
267
+ >HelloWorld
268
+ </text>
269
+ <rect
270
+ x="140" y="320"
271
+ width="100" height="40"
272
+ fill="white"
273
+ stroke="#000000"
274
+ stroke-width="1"
275
+ />
276
+
277
+ <rect
278
+ x="165" y="330"
279
+ width="50" height="20"
280
+ fill="green"
281
+ stroke="#000000"
282
+ stroke-width="1"
283
+ />
284
+
285
+ </svg>
@@ -1,6 +1,6 @@
1
1
 
2
2
  module RubySVGLight
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
 
5
5
  class Document
6
6
  attr_reader :body
@@ -51,7 +51,6 @@ module RubySVGLight
51
51
  fill="#{local_options[:fill]}"/>
52
52
  }
53
53
 
54
- #The call below should be in method missing add_[circle|line|rectangle]
55
54
  update_size(x+radius, y+radius)
56
55
  @body << text
57
56
  end
@@ -103,22 +102,45 @@ module RubySVGLight
103
102
  centre_text = "text-anchor:middle; dominant-baseline:central;"
104
103
  local_options = calc_local_options(opts)
105
104
 
105
+ text_vertical_centre = local_options[:text_centre] ||
106
+ local_options[:text_vertical_middle] ||
107
+ local_options[:text_vertical_centre] ||
108
+ local_options[:text_v_middle] ||
109
+ local_options[:text_v_centre]
110
+
111
+ text_horizontal_centre = local_options[:text_centre] ||
112
+ local_options[:text_horizontal_middle] ||
113
+ local_options[:text_horizontal_centre] ||
114
+ local_options[:text_h_middle] ||
115
+ local_options[:text_h_centre]
116
+
117
+
118
+ style = ""
119
+ style << "dominant-baseline: central; " if text_vertical_centre
120
+
121
+ style << "text-anchor: top; " if local_options[:text_horizontal_top]
122
+ style << "text-anchor: middle; " if text_horizontal_centre
123
+ style << "text-anchor: bottom; " if local_options[:text_horizontal_bottom]
124
+
106
125
 
107
126
  #Stroke is outline
108
127
  #fill is normal font. ie for text fill gets stroke colour
109
128
  text = %{<text
110
- x="#{x}" y="#{y}"
129
+ x="#{x}" y="#{y}" }
130
+
131
+ text << %{
132
+ style="#{style}" } unless style == ""
133
+
134
+ text << %{
111
135
  font-size="#{local_options[:font_size]}"
112
136
  fill="#{local_options[:stroke]}"
113
137
  font-family="Sans"
114
138
  >#{input_text}
115
139
  </text>
116
140
  }
117
- #{centre_text}"
118
- # xml:space="preserve"
119
- #Do not know height or width of text only the anchor
120
- update_size(x, y)
121
- @body << text
141
+ #Do not know height or width of text only the anchor
142
+ update_size(x, y)
143
+ @body << text
122
144
  end
123
145
 
124
146
  def options(opts={})
@@ -172,12 +194,6 @@ module RubySVGLight
172
194
  end
173
195
 
174
196
 
175
- #def finalise
176
- # #Maybe add the initial and closing things here so we are just noramlly dealing drawn components
177
- # @body.insert(0, header)
178
- # @body.insert(-1, footer)
179
- #end
180
-
181
197
  # to_file includes header and footers for a complete svg file
182
198
  def to_file( filename )
183
199
  File.open(filename, 'w') do |f|
@@ -213,7 +229,11 @@ end
213
229
 
214
230
 
215
231
  if $0 == __FILE__
232
+ filename = 'test.svg'
233
+
216
234
  a = RubySVGLight::Document.new()
217
235
  a.circle(20,10,10)
218
- a.to_file('test.svg')
236
+ a.to_file( filename )
237
+
238
+ puts "Created #{filename}"
219
239
  end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ def shape_contains( shape )
4
+ #This has been split over 2 lines to fix a bug in my syntax highlighter :(
5
+ regex = %{<svg[\\w\\W]*>[\\W]*<#{shape}[\\w\\W]*\/>[\\W]*<\/svg>}
6
+ return /#{regex}/
7
+ end
8
+
9
+
10
+
11
+ describe RubySVGLight do
12
+
13
+ #Hooks
14
+ before( :each ) do
15
+ @canvas = RubySVGLight::Document.new()
16
+ end
17
+
18
+
19
+
20
+ #Tests
21
+ it "Draw a circle x=10, y=20, r=30" do
22
+ @canvas.circle(10,20,30)
23
+
24
+ @canvas.to_s.should match shape_contains( 'circle' )
25
+ @canvas.to_s.should include %{cx="10"}
26
+ @canvas.to_s.should include %{cy="20"}
27
+ @canvas.to_s.should include %{r="30"}
28
+ end
29
+
30
+
31
+
32
+ it "Draw a rectangle x=10, y=20, width=30, height=40" do
33
+ @canvas.rectangle(10,20,30,40)
34
+
35
+ @canvas.to_s.should match shape_contains( 'rect' )
36
+ @canvas.to_s.should include %{x="10"}
37
+ @canvas.to_s.should include %{y="20"}
38
+ @canvas.to_s.should include %{width="30"}
39
+ @canvas.to_s.should include %{height="40"}
40
+ end
41
+
42
+
43
+
44
+ it "Draw a line x=10, y=20, width=30, height=40" do
45
+ @canvas.line(10,20,30,40)
46
+
47
+ #SVG lines are drawn specifying start and end coordinates.
48
+ #RubySVGLite uses start coordinates and height width to make it consitent with other shapes.
49
+ @canvas.to_s.should match shape_contains( 'line' )
50
+ @canvas.to_s.should include %{x1="10"}
51
+ @canvas.to_s.should include %{y1="20"}
52
+ @canvas.to_s.should include %{x2="#{10+30}"}
53
+ @canvas.to_s.should include %{y2="#{20+40}"}
54
+ end
55
+
56
+
57
+
58
+ it "Draw an ellipse x=10, y=20, width=30, height=40" do
59
+ @canvas.ellipse(10,20,30,40)
60
+
61
+ @canvas.to_s.should match shape_contains( 'ellipse' )
62
+ @canvas.to_s.should include %{cx="10"}
63
+ @canvas.to_s.should include %{cy="20"}
64
+ @canvas.to_s.should include %{rx="30"}
65
+ @canvas.to_s.should include %{ry="40"}
66
+ end
67
+
68
+ end
69
+
70
+
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ def style_contains( format )
4
+ #This has been split over 2 lines to fix a bug in my syntax highlighter :(
5
+ regex = %{style=\"(.*;)* ?#{format};(.*;)* ? \"}
6
+ return /#{regex}/
7
+ end
8
+
9
+ describe RubySVGLight do
10
+
11
+ #Hooks
12
+ before( :each ) do
13
+ @canvas = RubySVGLight::Document.new()
14
+ # 10 Random characters for test string changes for each test
15
+ @text = (0...10).map{ (('A'..'Z').to_a + ('a'..'z').to_a)[rand(52)] }.join
16
+ end
17
+
18
+ after( :each ) do
19
+ #Verify that actual text was included regardless of options used
20
+ @canvas.to_s.should include ">#{@text}\n </text>"
21
+ end
22
+
23
+
24
+
25
+
26
+
27
+ #Tests
28
+ it "Text, default font size" do
29
+ @canvas.text( 0, 0, @text)
30
+
31
+ @canvas.to_s.should include %{font-size="24px"}
32
+ end
33
+
34
+ it "Text, set fontsize with local option" do
35
+ @canvas.text( 0, 0, @text, {:font_size=>'100px'})
36
+
37
+ @canvas.to_s.should include %{font-size="100px"}
38
+ end
39
+
40
+ it "Text, set fontsize with global option" do
41
+ @canvas.options( {:font_size=>'100px'} )
42
+ @canvas.text( 0, 0, @text)
43
+
44
+ @canvas.to_s.should include %{font-size="100px"}
45
+ end
46
+
47
+
48
+
49
+
50
+
51
+ # The 4 ways to vertically centre text
52
+ it "Text, Vertical centre with :text_vertical_centre" do
53
+ @canvas.text( 0, 0, @text, {:text_vertical_centre=>true})
54
+
55
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
56
+ end
57
+
58
+ it "Text, Vertical centre with :text_vertical_middle" do
59
+ @canvas.text( 0, 0, @text, {:text_vertical_middle=>true})
60
+
61
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
62
+ end
63
+
64
+ it "Text, Vertical centre with :text_v_centre" do
65
+ @canvas.text( 0, 0, @text, {:text_v_centre=>true})
66
+
67
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
68
+ end
69
+
70
+ it "Text, Vertical centre with :text_v_middle" do
71
+ @canvas.text( 0, 0, @text, {:text_v_middle=>true})
72
+
73
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
74
+ end
75
+
76
+
77
+
78
+
79
+
80
+ # The 4 ways to horizontally centre text
81
+ it "Text, Horizontal centre with :text_horizontal_centre" do
82
+ @canvas.text( 0, 0, @text, {:text_horizontal_centre=>true})
83
+
84
+ @canvas.to_s.should match style_contains("text-anchor: middle")
85
+ end
86
+
87
+ it "Text, Horizontal centre with :text_horizontal_middle" do
88
+ @canvas.text( 0, 0, @text, {:text_horizontal_middle=>true})
89
+
90
+ @canvas.to_s.should match style_contains("text-anchor: middle")
91
+ end
92
+ it "Text, Horizontal centre with :text_h_centre" do
93
+ @canvas.text( 0, 0, @text, {:text_h_centre=>true})
94
+
95
+ @canvas.to_s.should match style_contains("text-anchor: middle")
96
+ end
97
+
98
+ it "Text, Horizontal centre with :text_h_middle" do
99
+ @canvas.text( 0, 0, @text, {:text_h_middle=>true})
100
+
101
+ @canvas.to_s.should match style_contains("text-anchor: middle")
102
+ end
103
+
104
+
105
+
106
+
107
+
108
+ #Vertical and Horizontal centre text
109
+ it "Text, Horizintal and Vertical centre with :text_horizontal_centre and :text_vertical_centre" do
110
+ @canvas.text( 0, 0, @text, {:text_horizontal_centre=>true,:text_vertical_centre=>true})
111
+
112
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
113
+ @canvas.to_s.should match style_contains("text-anchor: middle")
114
+ end
115
+
116
+ it "Text, Horizintal and Vertical centre with :text_centre" do
117
+ @canvas.text( 0, 0, @text, {:text_centre=>true})
118
+
119
+ @canvas.to_s.should match style_contains("dominant-baseline: central")
120
+ @canvas.to_s.should match style_contains("text-anchor: middle")
121
+ end
122
+
123
+
124
+ end
125
+
126
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_svg_light
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morgan Prior
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-11 00:00:00 +01:00
18
+ date: 2011-06-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,11 +29,18 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - LICENSE.rtf
32
+ - README.md
33
+ - HISTORY.md
34
+ - Rakefile
32
35
  - examples/shapes.rb
33
36
  - examples/shapes.svg
37
+ - examples/text_position.rb
38
+ - examples/text_position.svg
34
39
  - lib/ruby_svg.rb
35
40
  - lib/ruby_svg.rb.original
36
41
  - lib/ruby_svg_light.rb
42
+ - spec/ruby_svg_light_shapes_spec.rb
43
+ - spec/ruby_svg_light_text_spec.rb
37
44
  - spec/ruby_svg_light_width_spec.rb
38
45
  - spec/spec_helper.rb
39
46
  has_rdoc: true