class Rasem::SVGPath

SVG Path element, with ruby methods to describe the path

Public Class Methods

new(img = nil, attributes={}, &block) click to toggle source
Calls superclass method 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

arcTo(dx, dy, rx, ry, axis_rotation, large_arc_flag, sweep_flag) click to toggle source

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
arcToA(dx, dy, rx, ry, axis_rotation, large_arc_flag, sweep_flag) click to toggle source
# 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() click to toggle source

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(dx, dy, x1, y1, x2, y2) click to toggle source

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
curveToA(dx, dy, x1, y1, x2, y2) click to toggle source
# 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
hlineTo(x) click to toggle source

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
hlineToA(x) click to toggle source
# File lib/rasem/svg_image.rb, line 581
def hlineToA(x)
  add_d("H#{x}")
end
lineTo(x, y) click to toggle source

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
lineToA(x, y) click to toggle source
# File lib/rasem/svg_image.rb, line 565
def lineToA(x, y)
  add_d("L#{x},#{y}")
end
moveTo(x, y) click to toggle source

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
moveToA(x, y) click to toggle source
# File lib/rasem/svg_image.rb, line 549
def moveToA(x, y)
  add_d("M#{x},#{y}")
end
qcurveTo(dx, dy, x1, y1) click to toggle source

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
qcurveToA(dx, dy, x1, y1) click to toggle source
# File lib/rasem/svg_image.rb, line 649
def qcurveToA(dx, dy, x1, y1)
  add_d("Q#{x1},#{y1} #{dx},#{dy}")
end
scurveTo(dx, dy, x2, y2) click to toggle source

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
scurveToA(dx, dy, x2, y2) click to toggle source
# File lib/rasem/svg_image.rb, line 632
def scurveToA(dx, dy, x2, y2)
  add_d("S#{x2},#{y2} #{dx},#{dy}")
end
sqcurveTo(dx, dy) click to toggle source

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
sqcurveToA(dx, dy) click to toggle source
# File lib/rasem/svg_image.rb, line 666
def sqcurveToA(dx, dy)
  add_d("T#{dx},#{dy}")
end
vlineTo(y) click to toggle source

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
vlineToA(y) click to toggle source
# File lib/rasem/svg_image.rb, line 597
def vlineToA(y)
  add_d("V#{y}")
end

Private Instance Methods

add_d(op) click to toggle source
# File lib/rasem/svg_image.rb, line 707
def add_d(op)
  @attributes[:d] = @attributes[:d] + " " + op
end