Class: GSpotMichael::Swatch

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#populationObject

Returns the value of attribute population.



243
244
245
# File 'lib/g_spot_michael.rb', line 243

def population
  @population
end

#rgbObject

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_colorObject



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_colorObject



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

#hexObject



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

#hslObject



251
252
253
# File 'lib/g_spot_michael.rb', line 251

def hsl
  @hsl ||= rgb_to_hsl @rgb[0], @rgb[1], @rgb[2]
end