Class: SVG::Node::Path

Inherits:
SVG::Node show all
Defined in:
lib/svg/node/path.rb

Instance Method Summary (collapse)

Methods inherited from SVG::Node

#[]=, #current_transformation, #scale, #translate, #xpath

Methods included from SVG::NodeHelpers

#clip_path, #g, #path, #rect

Constructor Details

- (Path) initialize(properties = {}) {|SVG::Node::Path| ... }

Creates a new path node.

Yields:



9
10
11
# File 'lib/svg/node/path.rb', line 9

def initialize(properties = {}, &block)
  super "path", properties, &block
end

Instance Method Details

- (Object) close_path

Closes the current subpath by drawing a straight line from the current point to current subpath's initial point. Equivalent to "Z".



15
16
17
# File 'lib/svg/node/path.rb', line 15

def close_path
  append_path_data "Z"
end

- (Object) curve_to(x1, y1, x2, y2, x, y) Also known as: c

Draws a cubic B??zier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. All coordinates are relative.

Equivalent to "c".



32
33
34
# File 'lib/svg/node/path.rb', line 32

def curve_to(x1, y1, x2, y2, x, y)
  append_path_data "c", x1, y1, x2, y2, x, y
end

- (Object) curve_to!(x1, y1, x2, y2, x, y) Also known as: C

Draws a cubic B??zier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. All coordinates are absolute.

Equivalent to "C".



50
51
52
# File 'lib/svg/node/path.rb', line 50

def curve_to!(x1, y1, x2, y2, x, y)
  append_path_data "C", x1, y1, x2, y2, x, y
end

- (Object) line_to(x, y) Also known as: l

Draws a line from the current point to the given relative (x,y) coordinate which becomes the new current point. Equivalent to "L".



60
61
62
# File 'lib/svg/node/path.rb', line 60

def line_to(x, y)
  append_path_data "l", x, y
end

- (Object) line_to!(x, y) Also known as: L

Draws a line from the current point to the given absolute (x,y) coordinate which becomes the new current point. Equivalent to "L".



70
71
72
# File 'lib/svg/node/path.rb', line 70

def line_to!(x, y)
  append_path_data "L", x, y
end

- (Object) move_to(x, y) Also known as: m

Starts a new sub-path at the given relative (x,y) coordinate. Equivalent to "M".



80
81
82
# File 'lib/svg/node/path.rb', line 80

def move_to(x, y)
  append_path_data "m", x, y
end

- (Object) move_to!(x, y) Also known as: M

Starts a new sub-path at the given absolute (x,y) coordinate. Equivalent to "M".



90
91
92
# File 'lib/svg/node/path.rb', line 90

def move_to!(x, y)
  append_path_data "M", x, y
end

- (Object) smooth_curve_to(x2, y2, x, y) Also known as: s

Draws a smooth B??zier curve. See www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands for details. Equivalent to "s"



98
99
100
# File 'lib/svg/node/path.rb', line 98

def smooth_curve_to(x2, y2, x, y)
  append_path_data "s", x2, y2, x, y
end

- (Object) smooth_curve_to!(x2, y2, x, y) Also known as: S

Draws a smooth B??zier curve. See www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands for details. Equivalent to "S"



106
107
108
# File 'lib/svg/node/path.rb', line 106

def smooth_curve_to!(x2, y2, x, y)
  append_path_data "S", x2, y2, x, y
end