svgle 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69eca805f2560b1d9b85b03678c7f9046a534440
4
- data.tar.gz: a4b5d64859f9b143fe5a943cfb55da209f3942ad
3
+ metadata.gz: 735387a31aa3a8f3f0c94d85245c1a5b4cf04a4c
4
+ data.tar.gz: 14992ed09ea03bb29aa0bf4c92b8ac6aaa6c1845
5
5
  SHA512:
6
- metadata.gz: db8d0fc540d8572e7a856cf2f0d417888dd40c24e2809c7f60573db8b5d91798ebff1cdabbdb99631530b7ee975d4fde74547627209eb388e1d6ae8b98b326ad
7
- data.tar.gz: 7ce7fc827cd0b04045b7ef0bef3f41999155b969ab584b2a8562e8be4ef948b74a6e891182ed841eb412e9ca7e995bb15206fe19e6a6c8447a0d884fcd39d4e3
6
+ metadata.gz: 807a97089d5543c86d62a6509aa907c126b507b58d136bf76ae05bbf47632c577547768ba94ea1bf833e21bba5be0614d58af9ff582cc5fae00bf205541aaee1
7
+ data.tar.gz: d40d7cc82298ba522f72902aa695f0e7636fc7f148c3b43843629f3c9a9ae6ac4dae2ab02c3c038e5ece1f79d953c9a2165845b664281bd913543161edb95883
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/svgle.rb CHANGED
@@ -64,11 +64,14 @@ class Svgle < Rexle
64
64
 
65
65
  def initialize(name=nil, value: nil, attributes: Attributes.new(parent: self), rexle: nil)
66
66
  super(name, value: value, attributes: attributes, rexle: rexle)
67
+
68
+ @boundary_box = [[0,0,0,0]]
67
69
  end
68
70
 
69
71
  def self.attr2_accessor(*a)
70
72
 
71
73
  a.concat %i(id transform)
74
+ a.concat %i(onmousemove) # DOM events
72
75
 
73
76
  a.each do |attribute|
74
77
 
@@ -91,6 +94,15 @@ class Svgle < Rexle
91
94
  def style()
92
95
  attributes.style(@rexle)
93
96
  end
97
+
98
+
99
+ def hotspot?(x,y)
100
+
101
+ (boundary.first.is_a?(Array) ? boundary : [boundary]).all? do |box|
102
+ x1, y1, x2, y2 = box
103
+ (x1..x2).include? x and (y1..y2).include? y
104
+ end
105
+ end
94
106
  end
95
107
 
96
108
  class A < Element
@@ -101,42 +113,81 @@ class Svgle < Rexle
101
113
 
102
114
  class Circle < Element
103
115
  attr2_accessor *%i(cx cy r stroke stroke-width)
116
+ def boundary()
117
+ [0,0,0,0]
118
+ end
104
119
  end
105
120
 
106
121
  class Ellipse < Element
107
122
  attr2_accessor *%i(cx cy rx ry)
123
+ def boundary()
124
+ [0,0,0,0]
125
+ end
108
126
  end
109
127
 
110
128
  class G < Element
111
129
  attr2_accessor *%i(fill opacity)
130
+ def boundary()
131
+ [0,0,0,0]
132
+ end
112
133
  end
113
134
 
114
135
  class Line < Element
115
136
  attr2_accessor *%i(x1 y1 x2 y2)
137
+
138
+ def boundary()
139
+ [0,0,0,0]
140
+ end
116
141
  end
117
142
 
118
143
  class Path < Element
119
144
  attr2_accessor *%i(d stroke stroke-width fill)
145
+ def boundary()
146
+ [0,0,0,0]
147
+ end
120
148
  end
121
149
 
122
150
  class Polygon < Element
123
151
  attr2_accessor *%i(points)
152
+ def boundary()
153
+ [0,0,0,0]
154
+ end
124
155
  end
125
156
 
126
157
  class Polyline < Element
127
158
  attr2_accessor *%i(points)
159
+ def boundary()
160
+ [0,0,0,0]
161
+ end
128
162
  end
129
163
 
130
164
  class Rect < Element
165
+
131
166
  attr2_accessor *%i(x y width height rx ry)
167
+
168
+ def boundary()
169
+ x1, y1, w, h = [x, y, width, height].map(&:to_i)
170
+ [x1, y1, x1+w, y1+h]
171
+ end
172
+
132
173
  end
133
174
 
175
+ class Script < Element
176
+
177
+ end
178
+
134
179
  class Svg < Element
135
180
  attr2_accessor *%i(width height)
181
+ def boundary()
182
+ [0,0,0,0]
183
+ end
136
184
  end
137
185
 
138
186
  class Text < Element
139
187
  attr2_accessor *%i(x y fill)
188
+ def boundary()
189
+ [0,0,0,0]
190
+ end
140
191
  end
141
192
 
142
193
 
@@ -155,10 +206,18 @@ class Svgle < Rexle
155
206
  return Rexle::Comment.new(children.first) if name == '!-'
156
207
 
157
208
  type = {
209
+ circle: Svgle::Circle,
210
+ ellipse: Svgle::Ellipse,
158
211
  line: Svgle::Line,
159
212
  g: Svgle::G,
160
213
  svg: Svgle::Svg,
161
- doc: Rexle::Element
214
+ script: Svgle::Script,
215
+ doc: Rexle::Element,
216
+ polygon: Svgle::Polygon,
217
+ polyline: Svgle::Polyline,
218
+ path: Svgle::Path,
219
+ rect: Svgle::Rect,
220
+ text: Svgle::Text
162
221
  }
163
222
 
164
223
  element = type[name.to_sym].new(name, attributes: attributes, rexle: self)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  RmHuiq+pC3w5bbeKAS7PA41oFYzip80UozdgPsTbPSjT38fz3RwuIKWLTG0zOXty
32
32
  rUf4C1wr3bOSgQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-11-22 00:00:00.000000000 Z
34
+ date: 2015-11-23 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file