Class: Camalian::Palette

Inherits:
Array
  • Object
show all
Defined in:
lib/camalian/palette.rb

Instance Method Summary collapse

Instance Method Details

#light_colors(limit1, limit2) ⇒ Object


20
21
22
23
24
25
# File 'lib/camalian/palette.rb', line 20

def light_colors(limit1, limit2)
  min = [limit1, limit2].min
  max = [limit1, limit2].max
  table = self.dup
  Palette.new(table.delete_if { |color| color.l > max or color.l < min })
end

#sort_by_hueObject


8
9
10
# File 'lib/camalian/palette.rb', line 8

def sort_by_hue
  Palette.new(self.sort_by { |a| a.h }.reverse)
end

#sort_by_lightnessObject


4
5
6
# File 'lib/camalian/palette.rb', line 4

def sort_by_lightness
  Palette.new(self.sort_by { |a| a.l }.reverse)
end

#sort_by_saturationObject


16
17
18
# File 'lib/camalian/palette.rb', line 16

def sort_by_saturation
  Palette.new(self.sort_by { |a| a.s }.reverse)
end

#sort_similar_colorsObject


12
13
14
# File 'lib/camalian/palette.rb', line 12

def sort_similar_colors
  Palette.new(self.sort_by { |a| a.hsv })
end