r2dsvg 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/r2dsvg.rb +151 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84eb0cfa6361d540477455e70c6450d08822825ca2607c4256c95033f7c55ad
|
4
|
+
data.tar.gz: 64e440caeef0fee2217859010a47658e3aeaead60371f750bcc43533f2a4193e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ace20dd2b7df657494234fa3802738646a2c228ddd759e5d2aec69e00d6ae87f392ff3c82873fe379426698ef1499939f1b7e7d4a531bd4e576101c0c09a92a
|
7
|
+
data.tar.gz: 30cb870d1f80515cc8c645f3c7b7745d2ad2fdcd858b808aaa5fecd0866caeba49dd6e65bd63708fa78363344f86840e5ea7b9ee476b70bb0aa5c124ad06eb8c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/r2dsvg.rb
CHANGED
@@ -57,6 +57,43 @@ class R2dSvg
|
|
57
57
|
[:embed_audio, sources, e]
|
58
58
|
end
|
59
59
|
|
60
|
+
def circle(e, attributes, raw_style)
|
61
|
+
|
62
|
+
style = style_filter(attributes).merge(raw_style)
|
63
|
+
|
64
|
+
h = attributes
|
65
|
+
|
66
|
+
x, y, radius= %i(cx cy r).map{|x| h[x].to_i }
|
67
|
+
fill = h[:fill]
|
68
|
+
|
69
|
+
|
70
|
+
[:draw_circle, [x, y], radius, fill, style, render_all(e)]
|
71
|
+
end
|
72
|
+
|
73
|
+
# not yet implemented
|
74
|
+
#
|
75
|
+
def ellipse(e, attributes, raw_style)
|
76
|
+
|
77
|
+
style = style_filter(attributes).merge(raw_style)
|
78
|
+
h = attributes
|
79
|
+
|
80
|
+
x, y= %i(cx cy).map{|x| h[x].to_i }
|
81
|
+
width = h[:rx].to_i * 2
|
82
|
+
height = h[:ry].to_i * 2
|
83
|
+
|
84
|
+
[:draw_arc, [x, y, width, height], style, render_all(e)]
|
85
|
+
end
|
86
|
+
|
87
|
+
def line(e, attributes, raw_style)
|
88
|
+
|
89
|
+
style = style_filter(attributes).merge(raw_style)
|
90
|
+
|
91
|
+
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i }
|
92
|
+
|
93
|
+
[:draw_line, [x1, y1, x2, y2], style, render_all(e)]
|
94
|
+
end
|
95
|
+
|
96
|
+
|
60
97
|
def image(e, attributes, raw_style)
|
61
98
|
|
62
99
|
style = style_filter(attributes).merge(raw_style)
|
@@ -67,6 +104,24 @@ class R2dSvg
|
|
67
104
|
|
68
105
|
[:draw_image, [x, y, width, height], src, style, e, render_all(e)]
|
69
106
|
end
|
107
|
+
|
108
|
+
def polygon(e, attributes, raw_style)
|
109
|
+
|
110
|
+
style = style_filter(attributes).merge(raw_style)
|
111
|
+
points = attributes[:points].split(/\s+/). \
|
112
|
+
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
113
|
+
|
114
|
+
[:draw_polygon, points, style, e, render_all(e)]
|
115
|
+
end
|
116
|
+
|
117
|
+
def polyline(e, attributes, raw_style)
|
118
|
+
|
119
|
+
style = style_filter(attributes).merge(raw_style)
|
120
|
+
points = attributes[:points].split(/\s+/). \
|
121
|
+
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
122
|
+
|
123
|
+
[:draw_lines, points, style, render_all(e)]
|
124
|
+
end
|
70
125
|
|
71
126
|
def rect(e, attributes, raw_style)
|
72
127
|
|
@@ -128,6 +183,39 @@ class R2dSvg
|
|
128
183
|
|
129
184
|
end
|
130
185
|
|
186
|
+
def draw_arc(args)
|
187
|
+
|
188
|
+
dimensions, style = args
|
189
|
+
|
190
|
+
x, y, width, height = dimensions
|
191
|
+
|
192
|
+
#gc = gc_ini(fill: style[:fill] || :none)
|
193
|
+
#@area.window.draw_arc(gc, 1, x, y, width, height, 0, 64 * 360)
|
194
|
+
end
|
195
|
+
|
196
|
+
def draw_circle(args)
|
197
|
+
|
198
|
+
coords, radius, fill, style, e = args
|
199
|
+
|
200
|
+
x1, y1 = coords
|
201
|
+
|
202
|
+
if @debug then
|
203
|
+
puts 'inside draw_circle'.info
|
204
|
+
puts ('style: ' + style.inspect).debug
|
205
|
+
end
|
206
|
+
|
207
|
+
obj = Circle.new(
|
208
|
+
x: x1, y: y1,
|
209
|
+
radius: radius,
|
210
|
+
sectors: 32,
|
211
|
+
color: style[:fill],
|
212
|
+
z: style[:"z-index"].to_i
|
213
|
+
)
|
214
|
+
e.obj = obj if e.respond_to? :obj=
|
215
|
+
@window.add obj
|
216
|
+
|
217
|
+
end
|
218
|
+
|
131
219
|
def draw_image(args)
|
132
220
|
|
133
221
|
dimensions, src, style, e = args
|
@@ -154,6 +242,69 @@ class R2dSvg
|
|
154
242
|
end
|
155
243
|
end
|
156
244
|
|
245
|
+
def draw_line(args)
|
246
|
+
|
247
|
+
coords, style, e = args
|
248
|
+
|
249
|
+
x1, y1, x2, y2 = coords
|
250
|
+
|
251
|
+
if @debug then
|
252
|
+
puts 'inside draw_rectangle'.info
|
253
|
+
puts ('style: ' + style.inspect).debug
|
254
|
+
end
|
255
|
+
|
256
|
+
obj = Line.new(
|
257
|
+
x1: x1, y1: y1,
|
258
|
+
x2: x2, y2: y2,
|
259
|
+
width: style[:"stroke-width"].to_f,
|
260
|
+
color: style[:"stroke"],
|
261
|
+
z: style[:"z-index"].to_i
|
262
|
+
)
|
263
|
+
|
264
|
+
e.obj = obj if e.respond_to? :obj=
|
265
|
+
@window.add obj
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
def draw_polygon(args)
|
270
|
+
|
271
|
+
points, style, e = args
|
272
|
+
|
273
|
+
puts ('points: ' + points.inspect).debug if @debug
|
274
|
+
coords = points
|
275
|
+
|
276
|
+
if @debug then
|
277
|
+
puts 'inside draw_polygon'.info
|
278
|
+
puts ('style: ' + style.inspect).debug
|
279
|
+
end
|
280
|
+
|
281
|
+
puts ('coords: ' + coords.inspect).debug if @debug
|
282
|
+
|
283
|
+
h = coords.map.with_index do |c2,i|
|
284
|
+
|
285
|
+
%w(x y).zip(c2).map {|key, c| [(key + (i+1).to_s).to_sym, c] }
|
286
|
+
|
287
|
+
end.flatten(1).to_h
|
288
|
+
puts ('triangle h: ' + h.inspect).debug if @debug
|
289
|
+
|
290
|
+
puts ('triangle h merged: ' + h.inspect).debug if @debug
|
291
|
+
obj = Triangle.new(h.merge({color: style[:fill], z: style[:"z-index"].to_i}))
|
292
|
+
e.obj = obj if e.respond_to? :obj=
|
293
|
+
@window.add obj
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
# not yet implemented
|
298
|
+
#
|
299
|
+
def draw_lines(args)
|
300
|
+
|
301
|
+
coords, width, style, e = args
|
302
|
+
|
303
|
+
x1, y1, x2, y2 = coords
|
304
|
+
|
305
|
+
|
306
|
+
end
|
307
|
+
|
157
308
|
def draw_rectangle(args)
|
158
309
|
|
159
310
|
coords, style, e = args
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r2dsvg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
7avBPtmJXpQsK1kfdmXP/+tfAIa7KGseabm2+ntraqYNgx3DqyZur8IRdJFi/DPc
|
36
36
|
113q/9KjkLj6C+dR0HuLRW1c
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-02-
|
38
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: svgle
|
metadata.gz.sig
CHANGED
Binary file
|