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.
11 12 13 |
# File 'lib/geo_pattern/color.rb', line 11 def initialize(html_color) @color = ::Color::RGB.from_html html_color end |
Instance Method Details
#to_html ⇒ Object
23 24 25 |
# File 'lib/geo_pattern/color.rb', line 23 def to_html color.html end |
#to_svg ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/geo_pattern/color.rb', line 15 def to_svg r = (color.r * 255).round g = (color.g * 255).round b = (color.b * 255).round format("rgb(%<r>d, %<g>d, %<b>d)", r: r, g: g, b: b) end |