class Magick::RVG::Rect

Public Class Methods

new(width, height, x = 0, y = 0) click to toggle source

Define a width x height rectangle. The upper-left corner is at [x, y]. If either width or height is 0, the rectangle is not rendered. Use the RVG::ShapeConstructors#rect method to create Rect objects in a container.

Calls superclass method Magick::RVG::Transformable::new
# File lib/rvg/embellishable.rb, line 77
def initialize(width, height, x = 0, y = 0)
  super()
  width, height, x, y = Magick::RVG.convert_to_float(width, height, x, y)
  raise ArgumentError, "width, height must be >= 0 (#{width}, #{height} given)" if width < 0 || height < 0

  @args = [x, y, x + width, y + height]
  @primitive = :rectangle
end

Public Instance Methods

round(rx, ry = nil) click to toggle source

Specify optional rounded corners for a rectangle. The arguments are the x- and y-axis radii. If y is omitted it defaults to x.

# File lib/rvg/embellishable.rb, line 88
def round(rx, ry = nil)
  rx, ry = Magick::RVG.convert_to_float(rx, ry || rx)
  raise ArgumentError, "rx, ry must be >= 0 (#{rx}, #{ry} given)" if rx < 0 || ry < 0

  @args << rx << ry
  @primitive = :roundrectangle
  self
end