Sha256: 113b853fad85d554c39cac082bb52fa06b072232c77b5a198734758a2fe876a2

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

module RainbowColors
  class Palette
    def self.random_color
      red   = rand(255)
      green = rand(255)
      blue  = rand(255)
      
      RainbowColors::Convertor.hex_from_rgb({ red: red, green: green, blue: blue })
    end
    
    def self.adjust_saturation(colors, variance)
      colors.map! do |c|
        hsl = RainbowColors::Convertor.hsl_from_hex c
        if variance > 0
          hsl[:saturation] = hsl[:saturation] + variance if hsl[:saturation] + variance <= 100
        else
          hsl[:saturation] = hsl[:saturation] + variance if hsl[:saturation] + variance >= 0
        end
        RainbowColors::Convertor.hex_from_hsl hsl
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rainbow_colors-0.3.1 lib/rainbow_colors/palette.rb
rainbow_colors-0.3.0 lib/rainbow_colors/palette.rb