lib/prawn/svg/calculators/document_sizing.rb in prawn-svg-0.17.0 vs lib/prawn/svg/calculators/document_sizing.rb in prawn-svg-0.18.0
- old
+ new
@@ -3,11 +3,11 @@
attr_writer :document_width, :document_height
attr_writer :view_box, :preserve_aspect_ratio
attr_writer :requested_width, :requested_height
attr_reader :x_offset, :y_offset, :x_scale, :y_scale
- attr_reader :viewport_width, :viewport_height, :output_width, :output_height
+ attr_reader :viewport_width, :viewport_height, :viewport_diagonal, :output_width, :output_height
def initialize(bounds, attributes = nil)
@bounds = bounds
set_from_attributes(attributes) if attributes
end
@@ -44,9 +44,12 @@
@y_offset -= aspect.y
end
@viewport_width ||= width
@viewport_height ||= height
+
+ # SVG 1.1 section 7.10
+ @viewport_diagonal = Math.sqrt(@viewport_width**2 + @viewport_height**2) / Math.sqrt(2)
if @requested_width
scale = @requested_width / width
width = @requested_width
height *= scale