Class: GSpotMichael::Swatch
- Inherits:
-
Object
- Object
- GSpotMichael::Swatch
- Defined in:
- lib/g_spot_michael.rb
Instance Attribute Summary collapse
-
#population ⇒ Object
Returns the value of attribute population.
-
#rgb ⇒ Object
Returns the value of attribute rgb.
Instance Method Summary collapse
- #get_body_text_color ⇒ Object
- #get_title_text_color ⇒ Object
- #hex ⇒ Object
- #hsl ⇒ Object
-
#initialize(rgb, population = 1) ⇒ Swatch
constructor
A new instance of Swatch.
Constructor Details
#initialize(rgb, population = 1) ⇒ Swatch
Returns a new instance of Swatch.
245 246 247 248 249 |
# File 'lib/g_spot_michael.rb', line 245 def initialize(rgb, population=1) @rgb = rgb @population = population @yiq = 0 end |
Instance Attribute Details
#population ⇒ Object
Returns the value of attribute population.
243 244 245 |
# File 'lib/g_spot_michael.rb', line 243 def population @population end |
#rgb ⇒ Object
Returns the value of attribute rgb.
243 244 245 |
# File 'lib/g_spot_michael.rb', line 243 def rgb @rgb end |
Instance Method Details
#get_body_text_color ⇒ Object
264 265 266 267 |
# File 'lib/g_spot_michael.rb', line 264 def get_body_text_color ensure_text_colors (@yiq < 150) ? "#fff" : "#000" end |
#get_title_text_color ⇒ Object
259 260 261 262 |
# File 'lib/g_spot_michael.rb', line 259 def get_title_text_color ensure_text_colors (@yiq < 200) ? "#fff" : "#000" end |
#hex ⇒ Object
255 256 257 |
# File 'lib/g_spot_michael.rb', line 255 def hex "#" + ((1 << 24) + (@rgb[0] << 16) + (@rgb[1] << 8) + @rgb[2]).to_s(16).slice(1, 7) end |
#hsl ⇒ Object
251 252 253 |
# File 'lib/g_spot_michael.rb', line 251 def hsl @hsl ||= rgb_to_hsl @rgb[0], @rgb[1], @rgb[2] end |