Class: Treemap::ColorBase
- Inherits:
-
Object
- Object
- Treemap::ColorBase
- Defined in:
- lib/treemap/color_base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #blue(color) ⇒ Object
- #get_hex_color(value) ⇒ Object
- #get_rgb_color(value) ⇒ Object
- #green(color) ⇒ Object
- #red(color) ⇒ Object
- #to_html(width = 1, height = 20) ⇒ Object
- #to_rgb(color) ⇒ Object
Instance Method Details
#blue(color) ⇒ Object
33 34 35 36 |
# File 'lib/treemap/color_base.rb', line 33 def blue(color) color.sub!(/^#/, "") color[4,2].hex end |
#get_hex_color(value) ⇒ Object
15 16 17 |
# File 'lib/treemap/color_base.rb', line 15 def get_hex_color(value) # base classes override end |
#get_rgb_color(value) ⇒ Object
19 20 21 |
# File 'lib/treemap/color_base.rb', line 19 def get_rgb_color(value) # base classes override end |
#green(color) ⇒ Object
28 29 30 31 |
# File 'lib/treemap/color_base.rb', line 28 def green(color) color.sub!(/^#/, "") color[2,2].hex end |
#red(color) ⇒ Object
23 24 25 26 |
# File 'lib/treemap/color_base.rb', line 23 def red(color) color.sub!(/^#/, "") color[0,2].hex end |
#to_html(width = 1, height = 20) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/treemap/color_base.rb', line 42 def to_html(width=1, height=20) html = "<div>" index = @min while(index <= @max) html += "<span style=\"display: block; float: left;" html += "width: " + width.to_s + "px;" html += "height: " + height.to_s + "px;" html += "background-color: #" + get_hex_color(index) + ";" html += "\">" html += "<img width=\"1\" height=\"1\" />" html += "</span>" index += @increment end html += "</div>" html end |
#to_rgb(color) ⇒ Object
38 39 40 |
# File 'lib/treemap/color_base.rb', line 38 def to_rgb(color) [red(color), green(color), blue(color)] end |