r2dsvg 0.3.2 → 0.4.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 +58 -31
- data.tar.gz.sig +0 -0
- metadata +49 -29
- 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: 6da60aae210c67cdc2a6c908e0721ddcfc07a6b516fbdedb49fb8ba33736dd43
|
4
|
+
data.tar.gz: 3a2735d01e9aaa4e319c4481ecce6d811fac9f7506086627865fe4a8be40a3c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7370accf36a0322a26c0885f535f6fdc866fbbb65ff8f250d6a827d97251446fa716a71e2859a2f45873433f307001eaf78e48a491c5944fdacf04a3f8515cdc
|
7
|
+
data.tar.gz: 390bb9e097fb6660f8bc6f73750dab72f6b92500a521c094bf92b103311744cb5d41e7671e590b6d62116a2115afdb278e96a129c7fd0f8a98cad84bbd5e42ac
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/r2dsvg.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
require 'svgle'
|
9
|
+
require 'onedrb'
|
9
10
|
require 'ruby2d' # experimental gem depends upon simple2d binaries
|
10
11
|
require 'dom_render'
|
11
12
|
|
@@ -399,47 +400,45 @@ class R2dSvg
|
|
399
400
|
private
|
400
401
|
|
401
402
|
def draw(a)
|
403
|
+
|
404
|
+
threads = []
|
402
405
|
|
403
406
|
a.each do |rawx|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
407
|
+
|
408
|
+
threads << Thread.new do
|
409
|
+
x, *remaining = rawx
|
410
|
+
|
411
|
+
if x.is_a? Symbol then
|
412
|
+
method(x).call(args=remaining)
|
413
|
+
elsif x.is_a? String then
|
414
|
+
draw remaining
|
415
|
+
elsif x.is_a? Array
|
416
|
+
draw remaining
|
417
|
+
else
|
418
|
+
method(x).call(remaining.take 2)
|
419
|
+
end
|
415
420
|
end
|
416
|
-
|
421
|
+
|
417
422
|
end
|
423
|
+
|
424
|
+
threads.join
|
418
425
|
|
419
426
|
end
|
420
427
|
|
421
428
|
end
|
429
|
+
|
430
|
+
attr_reader :doc
|
422
431
|
|
423
|
-
def initialize(
|
424
|
-
|
425
|
-
@svg, @debug = svg, debug
|
426
|
-
|
427
|
-
doc = Svgle.new(svg, callback: self, debug: debug)
|
428
|
-
instructions = Render.new(doc, debug: debug).to_a
|
429
|
-
|
430
|
-
window = Window.new
|
431
|
-
drawing = DrawingInstructions.new window, debug: debug
|
432
|
-
puts ('instructions: ' + instructions.inspect).debug if @debug
|
432
|
+
def initialize(s, title: 'R2dSVG', debug: false)
|
433
433
|
|
434
|
-
@
|
435
|
-
window.set title: title, width: @width, height: @height
|
436
|
-
|
434
|
+
@debug = debug
|
437
435
|
|
438
|
-
|
436
|
+
@window = window = Window.new
|
439
437
|
|
440
|
-
|
438
|
+
@doc = read(s, title)
|
441
439
|
|
442
|
-
|
440
|
+
drb = OneDrb::Server.new host: '127.0.0.1', port: '57844', obj: self
|
441
|
+
Thread.new { drb.start }
|
443
442
|
|
444
443
|
window.on(:mouse_move) do |event|
|
445
444
|
mouse :mousemove, event
|
@@ -458,8 +457,32 @@ class R2dSvg
|
|
458
457
|
end
|
459
458
|
|
460
459
|
window.show
|
460
|
+
|
461
|
+
|
461
462
|
end
|
462
463
|
|
464
|
+
def read(s, title=@title)
|
465
|
+
|
466
|
+
svg, _ = RXFHelper.read(s)
|
467
|
+
doc = Svgle.new(svg, callback: self, debug: @debug)
|
468
|
+
instructions = Render.new(doc, debug: @debug).to_a
|
469
|
+
|
470
|
+
|
471
|
+
drawing = DrawingInstructions.new @window, debug: @debug
|
472
|
+
puts ('instructions: ' + instructions.inspect).debug if @debug
|
473
|
+
|
474
|
+
@width, @height = %i(width height).map{|x| doc.root.attributes[x].to_i }
|
475
|
+
@window.set title: title, width: @width, height: @height
|
476
|
+
|
477
|
+
Thread.new do
|
478
|
+
doc.root.xpath('//script').each {|x| eval x.text.unescape }
|
479
|
+
drawing.render instructions
|
480
|
+
end
|
481
|
+
|
482
|
+
doc
|
483
|
+
|
484
|
+
end
|
485
|
+
|
463
486
|
|
464
487
|
private
|
465
488
|
|
@@ -481,9 +504,13 @@ class R2dSvg
|
|
481
504
|
|
482
505
|
if block_given? then
|
483
506
|
valid = yield(x)
|
484
|
-
|
507
|
+
statement = x.method(('on' + action.to_s).to_sym).call()
|
508
|
+
puts 'statement: ' + statement.inspect if @debug
|
509
|
+
eval statement if valid
|
485
510
|
else
|
486
|
-
|
511
|
+
statement = x.method(('on' + action.to_s).to_sym).call()
|
512
|
+
puts 'statement: ' + statement.inspect if @debug
|
513
|
+
eval statement
|
487
514
|
end
|
488
515
|
|
489
516
|
else
|
@@ -505,7 +532,7 @@ class R2dSvg
|
|
505
532
|
eval x.method(:onmouseleave).call()
|
506
533
|
end
|
507
534
|
|
508
|
-
end
|
535
|
+
end
|
509
536
|
|
510
537
|
end
|
511
538
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMS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yQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAF94p0W/kawz6zAaPBAQYPK80pchIt5YmKgiHH/Ek
|
29
|
+
Vn7iww/aiHorCuAAW/2YPls4goVrSIMvHuV16P0qK1j3ylyyGoKnOn3PbpRrjHZu
|
30
|
+
3O9io3fqbVE2wo4kw8FKYEnv/vFFx53cIotYKhiyW5VKACM0AaolFtf2QBnLGuBN
|
31
|
+
6ete9dSMYppBMlf6Ah/EV3PfV6UV/2Pt51fASwU4DBwSsA1aPlvG9KjOq0UQfDHD
|
32
|
+
hiK5JelQEUxYRumvheEeAwKnIT8ir+Axt1ld93m7xwtNbDPu21fkGfJ6xFz8Ntme
|
33
|
+
Aca1IyhjpPV4IbGYIxNwH0xfeSBgJvp+XBqdcb52k34kdaJa3gsPl+1B4YksolOP
|
34
|
+
OD+mqzrShSSZRfL7bhBqXYELKZS5tayICrtujMxstwDGaDLwNVcN/CydQjAD6G+V
|
35
|
+
2z9cm0kGX/0pBfn8cMKC0JgNNNONx3uqiCAhaBEN35C8dqBjua/CK4rMoKEB7XQq
|
36
|
+
OAk+mR2SqyWecmZhdnsnm86T
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: svgle
|
@@ -57,26 +57,46 @@ dependencies:
|
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: 0.4.5
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: onedrb
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.1.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.1'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.1.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.1'
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: ruby2d
|
62
82
|
requirement: !ruby/object:Gem::Requirement
|
63
83
|
requirements:
|
64
84
|
- - "~>"
|
65
85
|
- !ruby/object:Gem::Version
|
66
|
-
version: '0.
|
86
|
+
version: '0.9'
|
67
87
|
- - ">="
|
68
88
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
89
|
+
version: 0.9.4
|
70
90
|
type: :runtime
|
71
91
|
prerelease: false
|
72
92
|
version_requirements: !ruby/object:Gem::Requirement
|
73
93
|
requirements:
|
74
94
|
- - "~>"
|
75
95
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
96
|
+
version: '0.9'
|
77
97
|
- - ">="
|
78
98
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
99
|
+
version: 0.9.4
|
80
100
|
- !ruby/object:Gem::Dependency
|
81
101
|
name: dom_render
|
82
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
143
|
- !ruby/object:Gem::Version
|
124
144
|
version: '0'
|
125
145
|
requirements: []
|
126
|
-
rubygems_version: 3.0.
|
146
|
+
rubygems_version: 3.0.3
|
127
147
|
signing_key:
|
128
148
|
specification_version: 4
|
129
149
|
summary: Experimental gem to render SVG within a Ruby2D application.
|
metadata.gz.sig
CHANGED
Binary file
|