lib/prawn/graphics.rb in prawn-1.3.0 vs lib/prawn/graphics.rb in prawn-2.0.0
- old
+ new
@@ -44,23 +44,23 @@
#
# pdf.move_to [100,50]
# pdf.move_to(100,50)
#
def move_to(*point)
- x,y = map_to_absolute(point)
- renderer.add_content("%.3f %.3f m" % [ x, y ])
+ xy = PDF::Core.real_params(map_to_absolute(point))
+ renderer.add_content("#{xy} m")
end
# Draws a line from the current drawing position to the specified point.
# The destination may be described as a tuple or a flattened list:
#
# pdf.line_to [50,50]
# pdf.line_to(50,50)
#
def line_to(*point)
- x,y = map_to_absolute(point)
- renderer.add_content("%.3f %.3f l" % [ x, y ])
+ xy = PDF::Core.real_params(map_to_absolute(point))
+ renderer.add_content("#{xy} l")
end
# Draws a Bezier curve from the current drawing position to the
# specified point, bounded by two additional points.
#
@@ -69,22 +69,25 @@
def curve_to(dest,options={})
options[:bounds] or raise Prawn::Errors::InvalidGraphicsPath,
"Bounding points for bezier curve must be specified "+
"as :bounds => [[x1,y1],[x2,y2]]"
- curve_points = (options[:bounds] << dest).map { |e| map_to_absolute(e) }
- renderer.add_content("%.3f %.3f %.3f %.3f %.3f %.3f c" %
- curve_points.flatten )
+ curve_points = PDF::Core.real_params(
+ (options[:bounds] << dest).flat_map { |e| map_to_absolute(e) })
+
+ renderer.add_content("#{curve_points} c")
end
# Draws a rectangle given <tt>point</tt>, <tt>width</tt> and
# <tt>height</tt>. The rectangle is bounded by its upper-left corner.
#
# pdf.rectangle [300,300], 100, 200
#
def rectangle(point,width,height)
x,y = map_to_absolute(point)
- renderer.add_content("%.3f %.3f %.3f %.3f re" % [ x, y - height, width, height ])
+ box = PDF::Core.real_params([x, y - height, width, height])
+
+ renderer.add_content("#{box} re")
end
# Draws a rounded rectangle given <tt>point</tt>, <tt>width</tt> and
# <tt>height</tt> and <tt>radius</tt> for the rounded corner. The rectangle
# is bounded by its upper-left corner.