Class: Magick::RVG::Rect
Overview
class Path
Instance Method Summary collapse
-
#initialize(width, height, x = 0, y = 0) ⇒ Rect
constructor
Define a width x height rectangle.
-
#round(rx, ry = nil) ⇒ Object
Specify optional rounded corners for a rectangle.
Methods inherited from Shape
Methods included from Duplicatable
Methods included from Transformable
#matrix, #rotate, #scale, #skewX, #skewY, #translate
Methods included from Stylable
Constructor Details
#initialize(width, height, x = 0, y = 0) ⇒ Rect
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.
80 81 82 83 84 85 86 87 88 |
# File 'lib/rvg/embellishable.rb', line 80 def initialize(width, height, x=0, y=0) super() width, height, x, y = Magick::RVG.convert_to_float(width, height, x, y) if width < 0 || height < 0 fail ArgumentError, "width, height must be >= 0 (#{width}, #{height} given)" end @args = [x, y, x+width, y+height] @primitive = :rectangle end |
Instance Method Details
#round(rx, ry = nil) ⇒ Object
Specify optional rounded corners for a rectangle. The arguments are the x- and y-axis radii. If y is omitted it defaults to x.
92 93 94 95 96 97 98 99 100 |
# File 'lib/rvg/embellishable.rb', line 92 def round(rx, ry=nil) rx, ry = Magick::RVG.convert_to_float(rx, ry || rx) if rx < 0 || ry < 0 fail ArgumentError, "rx, ry must be >= 0 (#{rx}, #{ry} given)" end @args << rx << ry @primitive = :roundrectangle self end |