Class: R2dEngine::App

Inherits:
Object
  • Object
show all
Defined in:
lib/r2dsvg/r2dsvg_module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



470
471
472
# File 'lib/r2dsvg/r2dsvg_module.rb', line 470

def doc
  @doc
end

Instance Method Details

#clearObject



473
474
475
# File 'lib/r2dsvg/r2dsvg_module.rb', line 473

def clear()
  @window.clear
end

#read(s, title = @title) ⇒ Object



477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/r2dsvg/r2dsvg_module.rb', line 477

def read(s, title=@title)
  @loaded = false
  @window.clear
  svg, _ = RXFHelper.read(s)    
  doc = Svgle.new(svg, callback: self, debug: @debug)
  instructions = Render.new(doc, debug: @debug).to_a

  
  drawing = DrawingInstructions.new @window, debug: @debug
  puts ('instructions: ' + instructions.inspect).debug if @debug

  @width, @height = %i(width height).map{|x| doc.root.attributes[x].to_i }
  @window.set title: title, width: @width, height: @height        
  
  threads = []
  
  threads << Thread.new do
    doc.root.xpath('//script').each {|x| eval x.text.unescape }      
    drawing.render instructions    
  end
  
  threads.join

  @loaded = true
  @doc = doc
  
end

#refreshObject



505
506
507
# File 'lib/r2dsvg/r2dsvg_module.rb', line 505

def refresh()
  puts 'do nothing' if @debug
end