Class: Sankey::Renderers::RVG
- Inherits:
-
Object
- Object
- Sankey::Renderers::RVG
- Defined in:
- lib/renderers/rvg.rb
Instance Method Summary collapse
-
#initialize(data, filename = nil, args = {}) ⇒ RVG
constructor
A new instance of RVG.
- #render ⇒ Object
Constructor Details
#initialize(data, filename = nil, args = {}) ⇒ RVG
Returns a new instance of RVG.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/renderers/rvg.rb', line 10 def initialize(data, filename = nil, args = {}) throw "data isn't ImageData" unless data.is_a? ImageData @grid = args[:grid] || false @vertices = data.vertices @filename = filename @width = args[:width] || data.width @height = args[:height] || data.height @width_ratio = 1.0 * @width / data.width @height_ratio = 1.0 * @height / data.height end |
Instance Method Details
#render ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/renderers/rvg.rb', line 21 def render canvas = Magick::ImageList.new canvas.new_image(@width, @height) draw_grid canvas if @grid @vertices.each { |v| draw_vertex canvas, v } if @filename.nil? return canvas.to_blob { self.format = 'PNG' } else canvas.write @filename end end |