Class: ColorExtract::Palette
- Inherits:
-
Object
- Object
- ColorExtract::Palette
- Includes:
- ColorUtil
- Defined in:
- lib/color_extract/palette.rb
Constant Summary
Constants included from ColorUtil
ColorUtil::K, ColorUtil::X, ColorUtil::Y, ColorUtil::Z
Instance Attribute Summary collapse
-
#main_color ⇒ Object
Returns the value of attribute main_color.
-
#max_pri_brightness ⇒ Object
Returns the value of attribute max_pri_brightness.
-
#raw_colors ⇒ Object
Returns the value of attribute raw_colors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file = nil) ⇒ Palette
constructor
A new instance of Palette.
-
#palette(accent_seed: nil) ⇒ Object
目前只生成一种配色方案.
- #palettes(opts = {}) ⇒ Object
Methods included from ColorUtil
#darken, #darken!, #dither, #hue_similarity, #lighten, #lighten!, #pure, #readable_textcolor, #reverse_color, #rgb2lab, #rgb_xyz, #similarity, #xyz_lab
Constructor Details
Instance Attribute Details
#main_color ⇒ Object
Returns the value of attribute main_color.
15 16 17 |
# File 'lib/color_extract/palette.rb', line 15 def main_color @main_color end |
#max_pri_brightness ⇒ Object
Returns the value of attribute max_pri_brightness.
15 16 17 |
# File 'lib/color_extract/palette.rb', line 15 def max_pri_brightness @max_pri_brightness end |
#raw_colors ⇒ Object
Returns the value of attribute raw_colors.
15 16 17 |
# File 'lib/color_extract/palette.rb', line 15 def raw_colors @raw_colors end |
Class Method Details
.from_colors(colors) ⇒ Object
8 9 10 11 12 |
# File 'lib/color_extract/palette.rb', line 8 def from_colors( colors ) new.tap do |palette| palette.raw_colors = colors.to_a end end |
Instance Method Details
#palette(accent_seed: nil) ⇒ Object
目前只生成一种配色方案
22 23 24 |
# File 'lib/color_extract/palette.rb', line 22 def palette( accent_seed: nil ) palettes( count: 1, accent_seed: accent_seed ).first end |
#palettes(opts = {}) ⇒ Object
26 27 28 29 |
# File 'lib/color_extract/palette.rb', line 26 def palettes( opts={} ) @raw_colors ||= @analytics.valuable_colors.map {|per, c| c } @palettes ||= gen_palettes( opts ) end |