Class: GeoPattern::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_pattern/color.rb

Instance Method Summary collapse

Constructor Details

#initialize(html_color) ⇒ 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_htmlObject


21
22
23
# File 'lib/geo_pattern/color.rb', line 21

def to_html
  color.html
end

#to_svgObject


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