class Rasem::SVGPath
SVG Path element, with ruby methods to describe the path
Public Class Methods
Rasem::SVGTagWithParent::new
# File lib/rasem/svg_image.rb, line 532 def initialize(img = nil, attributes={}, &block) attributes.merge!(:d => "") unless attributes.has_key? :d super(img, "path", attributes) end
Public Instance Methods
elliptical arc commands
Draws an elliptical arc from the current point to the point x,y. rx and ry are the elliptical radius in x and y direction. The x-rotation determines how much the arc is to be rotated around the x-axis. It only seems to have an effect when rx and ry have different values. The large-arc-flag doesn't seem to be used (can be either 0 or 1). Neither value (0 or 1) changes the arc. The sweep-flag determines the direction to draw the arc in.
# File lib/rasem/svg_image.rb, line 683 def arcTo(dx, dy, rx, ry, axis_rotation, large_arc_flag, sweep_flag) add_d("a#{rx},#{ry} #{axis_rotation} #{large_arc_flag},#{sweep_flag} #{dx},#{dy}") end
# File lib/rasem/svg_image.rb, line 688 def arcToA(dx, dy, rx, ry, axis_rotation, large_arc_flag, sweep_flag) add_d("A#{rx},#{ry} #{axis_rotation} #{large_arc_flag},#{sweep_flag} #{dx},#{dy}") end
close path command
Closes the path by drawing a line from current point to first point.
# File lib/rasem/svg_image.rb, line 699 def close add_d("Z") end
curveTo commands
Draws a cubic Bezier curve from current pen point to dx,dy. x1,y1 and x2,y2 are start and end control points of the curve, controlling how it bends.
# File lib/rasem/svg_image.rb, line 609 def curveTo(dx, dy, x1, y1, x2, y2) add_d("c#{x1},#{y1} #{x2},#{y2} #{dx},#{dy}") end
# File lib/rasem/svg_image.rb, line 614 def curveToA(dx, dy, x1, y1, x2, y2) add_d("C#{x1},#{y1} #{x2},#{y2} #{dx},#{dy}") end
horizontal lineTo commands
Draws a horizontal line to the point defined by x.
# File lib/rasem/svg_image.rb, line 576 def hlineTo(x) add_d("h#{x}") end
# File lib/rasem/svg_image.rb, line 581 def hlineToA(x) add_d("H#{x}") end
lineTo commands
Draws a line from current pen location to specified point x,y.
# File lib/rasem/svg_image.rb, line 560 def lineTo(x, y) add_d("l#{x},#{y}") end
# File lib/rasem/svg_image.rb, line 565 def lineToA(x, y) add_d("L#{x},#{y}") end
moveTo commands
Moves pen to specified point x,y without drawing.
# File lib/rasem/svg_image.rb, line 544 def moveTo(x, y) add_d("m#{x},#{y}") end
# File lib/rasem/svg_image.rb, line 549 def moveToA(x, y) add_d("M#{x},#{y}") end
quadratic Bezier curveTo commands
Draws a quadratic Bezier curve from current pen point to dx,dy. x1,y1 is the control point controlling how the curve bends.
# File lib/rasem/svg_image.rb, line 644 def qcurveTo(dx, dy, x1, y1) add_d("q#{x1},#{y1} #{dx},#{dy}") end
# File lib/rasem/svg_image.rb, line 649 def qcurveToA(dx, dy, x1, y1) add_d("Q#{x1},#{y1} #{dx},#{dy}") end
smooth curveTo commands
Draws a cubic Bezier curve from current pen point to dx,dy. x2,y2 is the end control point. The start control point is is assumed to be the same as the end control point of the previous curve.
# File lib/rasem/svg_image.rb, line 627 def scurveTo(dx, dy, x2, y2) add_d("s#{x2},#{y2} #{dx},#{dy}") end
# File lib/rasem/svg_image.rb, line 632 def scurveToA(dx, dy, x2, y2) add_d("S#{x2},#{y2} #{dx},#{dy}") end
smooth quadratic Bezier curveTo commands
Draws a quadratic Bezier curve from current pen point to dx,dy. The control point is assumed to be the same as the last control point used.
# File lib/rasem/svg_image.rb, line 661 def sqcurveTo(dx, dy) add_d("t#{dx},#{dy}") end
# File lib/rasem/svg_image.rb, line 666 def sqcurveToA(dx, dy) add_d("T#{dx},#{dy}") end
vertical lineTo commands
Draws a vertical line to the point defined by y.
# File lib/rasem/svg_image.rb, line 592 def vlineTo(y) add_d("v#{y}") end
# File lib/rasem/svg_image.rb, line 597 def vlineToA(y) add_d("V#{y}") end
Private Instance Methods
# File lib/rasem/svg_image.rb, line 707 def add_d(op) @attributes[:d] = @attributes[:d] + " " + op end