lib/prawn/svg/calculators/document_sizing.rb in prawn-svg-0.26.0 vs lib/prawn/svg/calculators/document_sizing.rb in prawn-svg-0.27.0
- old
+ new
@@ -1,9 +1,7 @@
module Prawn::SVG::Calculators
class DocumentSizing
- DEFAULT_WIDTH = 300
- DEFAULT_HEIGHT = 150
DEFAULT_ASPECT_RATIO = "xMidYMid meet"
attr_writer :document_width, :document_height
attr_writer :view_box, :preserve_aspect_ratio
@@ -28,30 +26,24 @@
@x_scale = @y_scale = 1
container_width = @requested_width || @bounds[0]
container_height = @requested_height || @bounds[1]
- @output_width = Pixels::Measurement.to_pixels(@document_width || @requested_width, container_width)
- @output_height = Pixels::Measurement.to_pixels(@document_height || @requested_height, container_height)
+ @output_width = Pixels::Measurement.to_pixels(@document_width || container_width, container_width)
+ @output_height = Pixels::Measurement.to_pixels(@document_height || container_height, container_height)
if @view_box
values = @view_box.strip.split(Prawn::SVG::Elements::COMMA_WSP_REGEXP)
@x_offset, @y_offset, @viewport_width, @viewport_height = values.map {|value| value.to_f}
if @viewport_width > 0 && @viewport_height > 0
- @output_width ||= container_width
- @output_height ||= @output_width * @viewport_height / @viewport_width
-
aspect = AspectRatio.new(@preserve_aspect_ratio, [@output_width, @output_height], [@viewport_width, @viewport_height])
@x_scale = aspect.width / @viewport_width
@y_scale = aspect.height / @viewport_height
@x_offset -= aspect.x / @x_scale
@y_offset -= aspect.y / @y_scale
end
else
- @output_width ||= Pixels::Measurement.to_pixels(DEFAULT_WIDTH, container_width)
- @output_height ||= Pixels::Measurement.to_pixels(DEFAULT_HEIGHT, container_height)
-
@viewport_width = @output_width
@viewport_height = @output_height
end
return if invalid?