lib/prawn/svg/document.rb in prawn-svg-0.17.0 vs lib/prawn/svg/document.rb in prawn-svg-0.18.0

- old
+ new

@@ -30,10 +30,12 @@ @sizing = Prawn::Svg::Calculators::DocumentSizing.new(bounds, @root.attributes) sizing.requested_width = options[:width] sizing.requested_height = options[:height] sizing.calculate + @axis_to_size = {:x => sizing.viewport_width, :y => sizing.viewport_height} + yield self if block_given? end def x(value) points(value, :x) @@ -46,10 +48,10 @@ def distance(value, axis = nil) value && points(value, axis) end def points(value, axis = nil) - Prawn::Svg::Calculators::Pixels.to_pixels(value, axis == :y ? sizing.viewport_height : sizing.viewport_width) + Prawn::Svg::Calculators::Pixels.to_pixels(value, @axis_to_size.fetch(axis, sizing.viewport_diagonal)) end def url_loader @url_loader ||= Prawn::Svg::UrlLoader.new(:enable_cache => cache_images) end