class Magick::RVG::PathData
as an argument to the RVG::ShapeConstructors#path method.
path by calling one or more methods. The path object can be passed
path. Each of the methods corresponds to a path command. Construct a
The PathData class provides an object-oriented way to produce an SVG
def add_points(req, *coords)
def add_points(req, *coords) return unless coords raise ArgumentError, "wrong number of coordinates specified. A multiple of #{req} required, #{req + coords.length} given." if coords.length % req != 0 coords.each { |c| @path << sprintf('%g', c) } end
def arc(abs, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y)
def arc(abs, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y) @path << sprintf('%s%g,%g %g %d %d %g,%g ', (abs ? 'A' : 'a'), rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y) end
def closepath(_abs = true)
Add a closepath command. The abs argument
def closepath(_abs = true) @path << 'Z' # ignore `abs' end
def curveto(abs, x1, y1, x2, y2, x, y, *coords)
true the coordinates are absolute, otherwise
If abs is
Add a curveto (cubic Bezier) command.
def curveto(abs, x1, y1, x2, y2, x, y, *coords) @path << sprintf('%s%g,%g %g,%g %g,%g ', (abs ? 'C' : 'c'), x1, y1, x2, y2, x, y) # "multiple sets of coordinates may be specified to draw a polybezier" add_points(6, *coords) end
def deep_copy(_h = nil)
- Private: -
def deep_copy(_h = nil) @path.dup end
def hlineto(abs, x)
true the coordinates are absolute, otherwise
Add a horizontal lineto command. If abs is
def hlineto(abs, x) @path << sprintf('%s%g ', (abs ? 'H' : 'h'), x) end
def initialize
def initialize @path = +'' end
def lineto(abs, x, y, *coords)
true the coordinates are absolute, otherwise
pairs may be specified. If abs is
Add a lineto command. Any number of x,y coordinate
def lineto(abs, x, y, *coords) @path << sprintf('%s%g,%g ', (abs ? 'L' : 'l'), x, y) # "a number of coordinate pairs may be specified to draw a polyline" add_points(2, *coords) end
def moveto(abs, x, y, *coords)
true the coordinates are absolute, otherwise
Add a moveto command. If abs is
def moveto(abs, x, y, *coords) @path << sprintf('%s%g,%g ', (abs ? 'M' : 'm'), x, y) # "subsequent pairs are treated as implicit lineto commands" add_points(2, *coords) end
def quadratic_curveto(abs, x1, y1, x, y, *coords)
true the coordinates are absolute, otherwise
If abs is
Add a quadratic Bezier curveto command.
def quadratic_curveto(abs, x1, y1, x, y, *coords) @path << sprintf('%s%g,%g %g,%g ', (abs ? 'Q' : 'q'), x1, y1, x, y) add_points(4, *coords) end
def smooth_curveto(abs, x2, y2, x, y, *coords)
true the coordinates are absolute, otherwise
If abs is
Add a smooth curveto (cubic Bezier) command.
def smooth_curveto(abs, x2, y2, x, y, *coords) @path << sprintf('%s%g,%g %g,%g ', (abs ? 'S' : 's'), x2, y2, x, y) # "multiple sets of coordinates may be specified to draw a polybezier" add_points(4, *coords) end
def smooth_quadratic_curveto(abs, x, y, *coords)
true the coordinates are absolute, otherwise
If abs is
Add a smooth quadratic Bezier curveto command.
def smooth_quadratic_curveto(abs, x, y, *coords) @path << sprintf('%s%g,%g ', (abs ? 'T' : 't'), x, y) add_points(2, *coords) end
def to_s
def to_s @path end
def vlineto(abs, y)
true the coordinates are absolute, otherwise
Add a vertical lineto command. If abs is
def vlineto(abs, y) @path << sprintf('%s%g ', (abs ? 'V' : 'v'), y) end