Module: Magick::RVG::ShapeConstructors
- Included in:
- ClipPath, Embellishable, Pattern
- Defined in:
- lib/rvg/embellishable.rb
Overview
Methods that construct basic shapes within a container
Instance Method Summary collapse
-
#circle(r, cx = 0, cy = 0) ⇒ Object
Draws a circle whose center is [
cx
,cy
] and radius isr
. -
#ellipse(rx, ry, cx = 0, cy = 0) ⇒ Object
Draws an ellipse whose center is [
cx
,cy
] and having a horizontal radiusrx
and vertical radiusry
. -
#line(x1 = 0, y1 = 0, x2 = 0, y2 = 0) ⇒ Object
Draws a line from [
x1
,y1
] to [x2
,y2
]. -
#path(path) ⇒ Object
Draws a path defined by an SVG path string or a PathData object.
-
#polygon(*points) ⇒ Object
Draws a polygon.
-
#polyline(*points) ⇒ Object
Draws a polyline.
-
#rect(width, height, x = 0, y = 0) ⇒ Object
Draws a rectangle whose upper-left corner is [
x
,y
] and with the specifiedwidth
andheight
.
Instance Method Details
#circle(r, cx = 0, cy = 0) ⇒ Object
Draws a circle whose center is [cx
, cy
] and radius is r
.
264 265 266 267 268 |
# File 'lib/rvg/embellishable.rb', line 264 def circle(r, cx=0, cy=0) circle = Circle.new(r, cx, cy) @content << circle return circle end |
#ellipse(rx, ry, cx = 0, cy = 0) ⇒ Object
Draws an ellipse whose center is [cx
, cy
] and having a horizontal radius rx
and vertical radius ry
.
272 273 274 275 276 |
# File 'lib/rvg/embellishable.rb', line 272 def ellipse(rx, ry, cx=0, cy=0) ellipse = Ellipse.new(rx, ry, cx, cy) @content << ellipse return ellipse end |
#line(x1 = 0, y1 = 0, x2 = 0, y2 = 0) ⇒ Object
Draws a line from [x1
, y1
] to [x2
, y2
].
279 280 281 282 283 |
# File 'lib/rvg/embellishable.rb', line 279 def line(x1=0, y1=0, x2=0, y2=0) line = Line.new(x1, y1, x2, y2) @content << line return line end |
#path(path) ⇒ Object
Draws a path defined by an SVG path string or a PathData object.
287 288 289 290 291 |
# File 'lib/rvg/embellishable.rb', line 287 def path(path) path = Path.new(path) @content << path return path end |
#polygon(*points) ⇒ Object
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.
314 315 316 317 318 |
# File 'lib/rvg/embellishable.rb', line 314 def polygon(*points) polygon = Polygon.new(*points) @content << polygon return polygon end |
#polyline(*points) ⇒ Object
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.
323 324 325 326 327 |
# File 'lib/rvg/embellishable.rb', line 323 def polyline(*points) polyline = Polyline.new(*points) @content << polyline return polyline end |
#rect(width, height, x = 0, y = 0) ⇒ Object
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
.
303 304 305 306 307 |
# File 'lib/rvg/embellishable.rb', line 303 def rect(width, height, x=0, y=0) rect = Rect.new(width, height, x, y) @content << rect return rect end |