Method: PDF::Wrapper#rectangle
- Defined in:
- lib/pdf/wrapper.rb
#rectangle(x, y, w, h, opts = {}) ⇒ Object
draw a rectangle starting at x,y with w,h dimensions. Parameters:
:x-
The x co-ordinate of the top left of the rectangle.
:y-
The y co-ordinate of the top left of the rectangle.
:w-
The width of the rectangle
:h-
The height of the rectangle
Options:
:color-
The colour of the rectangle outline
:fill_color-
The colour to fill the rectangle with. Defaults to nil (no fill)
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/pdf/wrapper.rb', line 455 def rectangle(x, y, w, h, opts = {}) # TODO: raise an error if any unrecognised options were supplied = {:color => @default_color, :fill_color => nil } .merge!(opts) # if the rectangle should be filled in if [:fill_color] set_color([:fill_color]) @context.rectangle(x, y, w, h).fill end set_color([:color]) @context.rectangle(x, y, w, h).stroke move_to(x+w, y+h) end |