r2dsvg 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/r2dsvg.rb +58 -31
  4. data.tar.gz.sig +0 -0
  5. metadata +49 -29
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecd5ec0962a23e7eb820a5e46386c608707a5c1aa1bf5dfc85d259b94977ab60
4
- data.tar.gz: cce9e032a47c4bc7ca2eb29e89b943e57ed908677ce0e203b7f5a3f93f0dbc0e
3
+ metadata.gz: 6da60aae210c67cdc2a6c908e0721ddcfc07a6b516fbdedb49fb8ba33736dd43
4
+ data.tar.gz: 3a2735d01e9aaa4e319c4481ecce6d811fac9f7506086627865fe4a8be40a3c3
5
5
  SHA512:
6
- metadata.gz: 51b383f6ff282e6e0dc6085ff6f1c486e195c10adbd769d96e284bcd6db31bbf600570c88ed7832f6f00ffc46876f97b7552a836c9ebe54682c62c36313239c0
7
- data.tar.gz: ea9389beabc45a478f37870be2192e31310c085ec64086e54c8068267b1f32a5eaeebfea47ff4400fd8c583373ab56fc4db7307ded178d86ef009df3325f8bec
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
- x, *remaining = rawx
406
-
407
- if x.is_a? Symbol then
408
- method(x).call(args=remaining)
409
- elsif x.is_a? String then
410
- draw remaining
411
- elsif x.is_a? Array
412
- draw remaining
413
- else
414
- method(x).call(remaining.take 2)
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(svg, title: 'R2dSVG', debug: false)
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
- @width, @height = %i(width height).map{|x| doc.root.attributes[x].to_i }
435
- window.set title: title, width: @width, height: @height
436
-
434
+ @debug = debug
437
435
 
438
- doc.root.xpath('//script').each {|x| eval x.text.unescape }
436
+ @window = window = Window.new
439
437
 
440
- drawing.render instructions
438
+ @doc = read(s, title)
441
439
 
442
- @doc = doc
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
- eval x.method(('on' + action.to_s).to_sym).call() if valid
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
- eval x.method(('on' + action.to_s).to_sym).call()
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.3.2
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
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMjI0MTUwMTAwWhcN
15
- MjAwMjI0MTUwMTAwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNy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ZvhnlC4Fne
34
- TYnQ3G01gSZ88tRRFI24m/UgpKE8uQ9SnkHYcgPVXBbq3kTUqrTSsWjE3V7hN7bB
35
- 7avBPtmJXpQsK1kfdmXP/+tfAIa7KGseabm2+ntraqYNgx3DqyZur8IRdJFi/DPc
36
- 113q/9KjkLj6C+dR0HuLRW1c
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: 2019-02-26 00:00:00.000000000 Z
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.8'
86
+ version: '0.9'
67
87
  - - ">="
68
88
  - !ruby/object:Gem::Version
69
- version: 0.8.1
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.8'
96
+ version: '0.9'
77
97
  - - ">="
78
98
  - !ruby/object:Gem::Version
79
- version: 0.8.1
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.1
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