Module | Magick::RVG::ShapeConstructors |
In: |
lib/rvg/embellishable.rb
|
Methods that construct basic shapes within a container
Draws a circle whose center is [cx, cy] and radius is r.
# File lib/rvg/embellishable.rb, line 263 263: def circle(r, cx=0, cy=0) 264: circle = Circle.new(r, cx, cy) 265: @content << circle 266: return circle 267: end
Draws an ellipse whose center is [cx, cy] and having a horizontal radius rx and vertical radius ry.
# File lib/rvg/embellishable.rb, line 271 271: def ellipse(rx, ry, cx=0, cy=0) 272: ellipse = Ellipse.new(rx, ry, cx, cy) 273: @content << ellipse 274: return ellipse 275: end
Draws a line from [x1, y1] to [x2, y2].
# File lib/rvg/embellishable.rb, line 278 278: def line(x1=0, y1=0, x2=0, y2=0) 279: line = Line.new(x1, y1, x2, y2) 280: @content << line 281: return line 282: end
Draws a polygon. The arguments are [x, y] pairs that define the points that make up the polygon. At least two points must be specified. If the last point is not the same as the first, adds an additional point to close the polygon.
# File lib/rvg/embellishable.rb, line 313 313: def polygon(*points) 314: polygon = Polygon.new(*points) 315: @content << polygon 316: return polygon 317: end
Draws a polyline. The arguments are [x, y] pairs that define the points that make up the polyline. At least two points must be specified.
# File lib/rvg/embellishable.rb, line 322 322: def polyline(*points) 323: polyline = Polyline.new(*points) 324: @content << polyline 325: return polyline 326: end
Draws a rectangle whose upper-left corner is [x, y] and with the specified width and height. Unless otherwise specified the rectangle has square corners. Returns a Rectangle object.
Draw a rectangle with rounded corners by calling the round method on the Rectangle object. rx and ry are the corner radii in the x- and y-directions. For example:
canvas.rect(width, height, x, y).round(8, 6)
If ry is omitted it defaults to rx.
# File lib/rvg/embellishable.rb, line 302 302: def rect(width, height, x=0, y=0) 303: rect = Rect.new(width, height, x, y) 304: @content << rect 305: return rect 306: end