Module: SVG::NodeHelpers

Included in:
Canvas, Node
Defined in:
lib/svg/node_helpers.rb

Instance Method Summary collapse

Instance Method Details

#clip_path(properties = {}) {|SVG::Node| ... } ⇒ SVG::Node

Creates a new clipPath node.

Parameters:

  • properties (Hash) (defaults to: {})

    a hash of properties to set on the clipPath node

Yields:

Returns:



9
10
11
12
13
14
15
# File 'lib/svg/node_helpers.rb', line 9

def clip_path(properties = {})
  SVG::Node.new "clipPath", properties do |clip_path|
    self << clip_path

    yield clip_path if block_given?
  end
end

#g(properties = {}) {|SVG::Node| ... } ⇒ SVG::Node

Creates a new graphics (`g`) node.

Parameters:

  • properties (Hash) (defaults to: {})

    a hash of properties to set on the graphics node

Yields:

Returns:



22
23
24
25
26
27
28
# File 'lib/svg/node_helpers.rb', line 22

def g(properties = {})
  SVG::Node.new "g", properties do |g|
    self << g

    yield g if block_given?
  end
end

#path(properties = {}) {|SVG::Node| ... } ⇒ SVG::Node

Creates a new path node.

Parameters:

  • properties (Hash) (defaults to: {})

    a hash of properties to set on the path node

Yields:

Returns:



35
36
37
38
39
40
41
# File 'lib/svg/node_helpers.rb', line 35

def path(properties = {})
  SVG::Node::Path.new properties do |path|
    self << path

    yield path if block_given?
  end
end

#rect(properties = {}) {|SVG::Node| ... } ⇒ SVG::Node

Creates a new rect node.

Parameters:

  • properties (Hash) (defaults to: {})

    a hash of properties to set on the rect node

Yields:

Returns:



48
49
50
51
52
53
54
# File 'lib/svg/node_helpers.rb', line 48

def rect(properties = {})
  SVG::Node.new "rect", properties do |rect|
    self << rect

    yield rect if block_given?
  end
end