class R2dEngine::Render
Public Instance Methods
audio(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 63 def audio(e, attributes) puts 'inside audio attributes: ' + attributes.inspect if @debug h = attributes sources = e.xpath('source').map do |x| h = x.attributes.to_h h.delete :style h end [:embed_audio, sources, e] end
circle(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 78 def circle(e, attributes) h = attributes x, y, radius= %i(cx cy r).map{|x| h[x].to_i } fill = h[:fill] [:draw_circle, [x, y], radius, fill, attributes, render_all(e)] end
ellipse(e, attributes)
click to toggle source
not yet implemented
# File lib/r2dsvg/r2dsvg_module.rb, line 93 def ellipse(e, attributes) h = attributes x, y= %i(cx cy).map{|x| h[x].to_i } width = h[:rx].to_i * 2 height = h[:ry].to_i * 2 [:draw_arc, [x, y, width, height], attributes, render_all(e)] end
g(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 104 def g(e, attributes) puts 'inside rect attributes: ' + attributes.inspect if @debug h = attributes x1, y1, width, height = %i(x y width height).map{|x| h[x].to_i } x2, y2, = x1 + width, y1 + height [:draw_rectangle, [x1, y1, x2, y2], attributes, e, render_all(e)] end
image(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 127 def image(e, attributes) h = attributes x, y, width, height = %i(x y width height).map{|x| h[x] ? h[x].to_i : nil } src = h[:'xlink:href'] [:draw_image, [x, y, width, height], src, attributes, e, render_all(e)] end
line(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 118 def line(e, attributes) x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i } [:draw_line, [x1, y1, x2, y2], attributes, render_all(e)] end
polygon(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 137 def polygon(e, attributes) points = attributes[:points].split(/\s+/). \ map {|x| x.split(/\s*,\s*/).map(&:to_i)} [:draw_polygon, points, attributes, e, render_all(e)] end
polyline(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 146 def polyline(e, attributes) points = attributes[:points].split(/\s+/). \ map {|x| x.split(/\s*,\s*/).map(&:to_i)} [:draw_lines, points, attributes, render_all(e)] end
rect(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 154 def rect(e, attributes) puts 'inside rect attributes: ' + attributes.inspect if @debug h = attributes x1, y1, width, height = %i(x y width height).map{|x| h[x].to_i } x2, y2, = x1 + width, y1 + height [:draw_rectangle, [x1, y1, x2, y2], attributes, e, render_all(e)] end
svg(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 168 def svg(e, attributes) h = attributes width, height = %i(width height).map{|x| h[x].to_i } [:draw_rectangle, [0, 0, width, height], attributes, render_all(e)] end
text(e, attributes)
click to toggle source
# File lib/r2dsvg/r2dsvg_module.rb, line 176 def text(e, attributes) attributes.merge!({font_size: '20'}) x, y = %i(x y).map{|x| attributes[x].to_i } [:draw_text, [x, y], e.text, attributes, e, render_all(e)] end