lib/prawn/graphics.rb in prawn-1.2.1 vs lib/prawn/graphics.rb in prawn-1.3.0

- old
+ new

@@ -45,22 +45,22 @@ # pdf.move_to [100,50] # pdf.move_to(100,50) # def move_to(*point) x,y = map_to_absolute(point) - add_content("%.3f %.3f m" % [ x, y ]) + renderer.add_content("%.3f %.3f m" % [ x, y ]) 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) - add_content("%.3f %.3f l" % [ x, y ]) + renderer.add_content("%.3f %.3f l" % [ x, y ]) end # Draws a Bezier curve from the current drawing position to the # specified point, bounded by two additional points. # @@ -70,22 +70,22 @@ 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) } - add_content("%.3f %.3f %.3f %.3f %.3f %.3f c" % + renderer.add_content("%.3f %.3f %.3f %.3f %.3f %.3f c" % curve_points.flatten ) 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) - add_content("%.3f %.3f %.3f %.3f re" % [ x, y - height, width, height ]) + renderer.add_content("%.3f %.3f %.3f %.3f re" % [ x, y - height, width, height ]) 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. @@ -237,11 +237,11 @@ move_to points[0] (points[1..-1] << points[0]).each do |point| line_to(*point) end # close the path - add_content "h" + renderer.add_content "h" end # Draws a rounded polygon from specified points using the radius to define bezier curves # # # draws a rounded filled in polygon @@ -253,11 +253,11 @@ points << points[0] << points[1] (sides).times do |i| rounded_vertex(radius, points[i], points[i + 1], points[i + 2]) end # close the path - add_content "h" + renderer.add_content "h" end # Creates a rounded vertex for a line segment used for building a rounded polygon # requires a radius to define bezier curve and three points. The first two points define @@ -274,19 +274,19 @@ # Strokes the current path. If a block is provided, yields to the block # before closing the path. See Graphics::Color for color details. # def stroke yield if block_given? - add_content "S" + renderer.add_content "S" end # Closes and strokes the current path. If a block is provided, yields to # the block before closing the path. See Graphics::Color for color details. # def close_and_stroke yield if block_given? - add_content "s" + renderer.add_content "s" end # Draws and strokes a rectangle represented by the current bounding box # def stroke_bounds @@ -362,11 +362,11 @@ # will be used. See the PDF reference, "Graphics -> Path Construction and # Painting -> Clipping Path Operators" for details on the difference. # def fill(options={}) yield if block_given? - add_content(options[:fill_rule] == :even_odd ? "f*" : "f") + renderer.add_content(options[:fill_rule] == :even_odd ? "f*" : "f") end # Closes, fills, and strokes the current path. If a block is provided, # yields to the block before closing the path. See Graphics::Color for # color details. @@ -376,17 +376,17 @@ # will be used. See the PDF reference, "Graphics -> Path Construction and # Painting -> Clipping Path Operators" for details on the difference. # def fill_and_stroke(options={}) yield if block_given? - add_content(options[:fill_rule] == :even_odd ? "b*" : "b") + renderer.add_content(options[:fill_rule] == :even_odd ? "b*" : "b") end # Closes the current path. # def close_path - add_content "h" + renderer.add_content "h" end ## # :method: stroke_rectangle # @@ -610,10 +610,10 @@ def current_line_width=(width) graphic_state.line_width = width end def write_line_width - add_content("#{current_line_width} w") + renderer.add_content("#{current_line_width} w") end def map_to_absolute(*point) x,y = point.flatten [@bounding_box.absolute_left + x, @bounding_box.absolute_bottom + y]