Class: GeoPattern::Color
- Inherits:
-
Object
- Object
- GeoPattern::Color
- Defined in:
- lib/geo_pattern/color.rb
Instance Method Summary collapse
-
#initialize(html_color) ⇒ Color
constructor
A new instance of Color.
- #to_html ⇒ Object
- #to_svg ⇒ Object
Constructor Details
#initialize(html_color) ⇒ Color
Returns a new instance of Color.
9 10 11 |
# File 'lib/geo_pattern/color.rb', line 9 def initialize(html_color) @color = ::Color::RGB.from_html html_color end |
Instance Method Details
#to_html ⇒ Object
21 22 23 |
# File 'lib/geo_pattern/color.rb', line 21 def to_html color.html end |
#to_svg ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/geo_pattern/color.rb', line 13 def to_svg r = (color.r * 255).round g = (color.g * 255).round b = (color.b * 255).round format('rgb(%d, %d, %d)', r, g, b) end |