Class: Bio::Graphics::ImageMap
- Inherits:
-
Object
- Object
- Bio::Graphics::ImageMap
- Defined in:
- lib/bio/graphics/image_map.rb
Overview
bio/graphics/image_map.rb - create the image map for clickable images
- Copyright
-
Copyright © 2007 Jan Aerts <[email protected]> Charles Comstock <[email protected]>
- License
-
Ruby’s
Defined Under Namespace
Classes: Element
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
Instance Method Summary collapse
- #add_element(left, top, right, bottom, url = nil) ⇒ Object
-
#flip_orientation(width) ⇒ Object
Switch horizontal to vertical orientation.
-
#initialize ⇒ ImageMap
constructor
A new instance of ImageMap.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ ImageMap
Returns a new instance of ImageMap.
9 10 11 |
# File 'lib/bio/graphics/image_map.rb', line 9 def initialize @elements = Array.new end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
12 13 14 |
# File 'lib/bio/graphics/image_map.rb', line 12 def elements @elements end |
Instance Method Details
#add_element(left, top, right, bottom, url = nil) ⇒ Object
14 15 16 |
# File 'lib/bio/graphics/image_map.rb', line 14 def add_element(left,top,right,bottom,url = nil) @elements.push(Element.new(left,top,right,bottom,url)) end |
#flip_orientation(width) ⇒ Object
Switch horizontal to vertical orientation
33 34 35 36 37 38 39 40 41 |
# File 'lib/bio/graphics/image_map.rb', line 33 def flip_orientation(width) @elements.each do |element| left, top, right, bottom = element.left, element.top, element.right, element.bottom element.left = top element.top = width - right element.right = bottom element.bottom = width - left end end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bio/graphics/image_map.rb', line 18 def to_s output = Array.new output.push('<map name="image_map" border="1">') @elements.each do |e| area = e.to_s if area != '' output.push(e.to_s) end end output.push('</map>') return output.join("\n") end |