Class: DomGlancy::SVG

Inherits:
Object
  • Object
show all
Defined in:
lib/dom_glancy/svg.rb

Instance Method Summary collapse

Constructor Details

#initialize(set_current_not_master, set_master_not_current, set_changed_master) ⇒ SVG

Returns a new instance of SVG.



7
8
9
10
11
# File 'lib/dom_glancy/svg.rb', line 7

def initialize(set_current_not_master, set_master_not_current, set_changed_master)
  @set_current_not_master = set_current_not_master
  @set_master_not_current = set_master_not_current
  @set_changed_master     = set_changed_master
end

Instance Method Details

#generate_svgObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dom_glancy/svg.rb', line 13

def generate_svg
  add_ids

  rectangles = make_rectangles

  width, height = get_window_size_from_rectangles(rectangles)
  s = svg_start(width, height)

  rectangles.each do |rectangle|
    rectangle_string = "      <rect id='#{rectangle[:js_id]}' x = '#{rectangle['left']}' y = '#{rectangle['top']}' width = '#{rectangle['width']}' height = '#{rectangle['height']}' fill = '#{rectangle[:fill]}' stroke = '#{rectangle[:stroke]}' stroke-width = '#{rectangle[:stroke_width]}' fill-opacity = '#{rectangle[:opacity]}' />\n"
    s += rectangle_string
  end

  s += svg_end
  s += "\n"
end