lib/prawn/graphics.rb in prawn-2.2.2 vs lib/prawn/graphics.rb in prawn-2.3.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + # graphics.rb : Implements PDF drawing primitives # # Copyright April 2008, Gregory Brown. All Rights Reserved. # # This is free software. Please see the LICENSE and COPYING files for details. @@ -146,15 +148,11 @@ # # # draw a line from [25, 75] to [100, 75] # horizontal_line 25, 100, :at => 75 # def horizontal_line(x1, x2, options = {}) - y1 = if options[:at] - options[:at] - else - y - bounds.absolute_bottom - end + y1 = options[:at] || y - bounds.absolute_bottom line(x1, y1, x2, y1) end # Draws a horizontal line from the left border to the right border of the @@ -196,40 +194,40 @@ # def circle(center, radius) ellipse(center, radius, radius) end - # Draws an ellipse of +x+ radius <tt>r1</tt> and +y+ radius <tt>r2</tt> - # with the centre-point at <tt>point</tt> as a complete subpath. The - # drawing point will be moved to the centre-point upon completion of the - # drawing the ellipse. + # Draws an ellipse of +x+ radius <tt>radius1</tt> and +y+ radius + # <tt>radius2</tt> with the centre-point at <tt>point</tt> as a complete + # subpath. The drawing point will be moved to the centre-point upon + # completion of the drawing the ellipse. # # # draws an ellipse with x-radius 25 and y-radius 50 # pdf.ellipse [100,100], 25, 50 # - def ellipse(point, r1, r2 = r1) + def ellipse(point, radius1, radius2 = radius1) x, y = point - l1 = r1 * KAPPA - l2 = r2 * KAPPA + l1 = radius1 * KAPPA + l2 = radius2 * KAPPA - move_to(x + r1, y) + move_to(x + radius1, y) # Upper right hand corner - curve_to [x, y + r2], - bounds: [[x + r1, y + l2], [x + l1, y + r2]] + curve_to [x, y + radius2], + bounds: [[x + radius1, y + l2], [x + l1, y + radius2]] # Upper left hand corner - curve_to [x - r1, y], - bounds: [[x - l1, y + r2], [x - r1, y + l2]] + curve_to [x - radius1, y], + bounds: [[x - l1, y + radius2], [x - radius1, y + l2]] # Lower left hand corner - curve_to [x, y - r2], - bounds: [[x - r1, y - l2], [x - l1, y - r2]] + curve_to [x, y - radius2], + bounds: [[x - radius1, y - l2], [x - l1, y - radius2]] # Lower right hand corner - curve_to [x + r1, y], - bounds: [[x + l1, y - r2], [x + r1, y - l2]] + curve_to [x + radius1, y], + bounds: [[x + l1, y - radius2], [x + radius1, y - l2]] move_to(x, y) end # Draws a polygon from the specified points. @@ -341,13 +339,13 @@ negative_axes_length: 20, color: '000000' }.merge(options) Prawn.verify_options( - [ - :at, :width, :height, :step_length, - :negative_axes_length, :color + %i[ + at width height step_length + negative_axes_length color ], options ) save_graphics_state do fill_color(options[:color]) @@ -632,15 +630,15 @@ horizontal_rule vertical_line curve circle_at circle ellipse_at ellipse polygon rounded_polygon rounded_vertex ] ops.product(shapes).each do |operation, shape| - class_eval <<-END + class_eval <<-METHOD, __FILE__, __LINE__ + 1 def #{operation}_#{shape}(*args) #{shape}(*args) #{operation} end - END + METHOD end private def current_line_width