Method: Color::Palette::MonoContrast#regenerate
- Defined in:
- lib/color/palette/monocontrast.rb
permalink #regenerate(background, foreground = nil) ⇒ Object
Generate the colour palettes.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/color/palette/monocontrast.rb', line 80 def regenerate(background, foreground = nil) foreground ||= background background = background.to_rgb foreground = foreground.to_rgb @background = {} @foreground = {} @background[-5] = background.darken_by(10) @background[-4] = background.darken_by(25) @background[-3] = background.darken_by(50) @background[-2] = background.darken_by(75) @background[-1] = background.darken_by(85) @background[ 0] = background @background[+1] = background.lighten_by(85) @background[+2] = background.lighten_by(75) @background[+3] = background.lighten_by(50) @background[+4] = background.lighten_by(25) @background[+5] = background.lighten_by(10) @foreground[-5] = calculate_foreground(@background[-5], foreground) @foreground[-4] = calculate_foreground(@background[-4], foreground) @foreground[-3] = calculate_foreground(@background[-3], foreground) @foreground[-2] = calculate_foreground(@background[-2], foreground) @foreground[-1] = calculate_foreground(@background[-1], foreground) @foreground[ 0] = calculate_foreground(@background[ 0], foreground) @foreground[+1] = calculate_foreground(@background[+1], foreground) @foreground[+2] = calculate_foreground(@background[+2], foreground) @foreground[+3] = calculate_foreground(@background[+3], foreground) @foreground[+4] = calculate_foreground(@background[+4], foreground) @foreground[+5] = calculate_foreground(@background[+5], foreground) end |