Class: SVG::Canvas

Inherits:
Document
  • Object
show all
Includes:
NodeHelpers
Defined in:
lib/svg/canvas.rb

Instance Method Summary collapse

Methods included from NodeHelpers

#clip_path, #g, #path, #rect

Constructor Details

#initialize(width, height) ⇒ Canvas

Returns a new instance of Canvas

Parameters:

  • width

    the canvas width

  • height

    the canvas height



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

def initialize(width, height)
  super()

  self.root = SVG::Node.new "svg",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    width: width,
    height: height
end

Instance Method Details

#<<(node) ⇒ Object

Adds the provided node to the root node.

Parameters:



20
21
22
# File 'lib/svg/canvas.rb', line 20

def <<(node)
  root << node
end

#[](property) ⇒ String

Returns the value of the property on the root node

Parameters:

  • property

    the property to return

Returns:

  • (String)

    the value of the property on the root node



26
27
28
# File 'lib/svg/canvas.rb', line 26

def [](property)
  root[property]
end

#[]=(property, value) ⇒ Object

Sets the value of the given property on the root node.

Parameters:

  • property

    the property to set

  • value

    the value to set the property to



34
35
36
# File 'lib/svg/canvas.rb', line 34

def []=(property, value)
  root[property] = value
end