Sha256: 4c8f86595098ab6901a22be595b9a038522d730b2c02130d940c10b8a35f2cec

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

module Cheers
  class Decoration < ImageComponent
    
    IMAGES = %w( decorations/1.png
                 decorations/2.png )
    
    attr_reader :color, :image
    
    def initialize(canvas, color_randomizer, image_randomizer = nil)
      super
      
      @color = ContrastingColorPicker.new(Avatar::BACKGROUND_COLORS, extract_background_color(canvas)).pick(color_randomizer)
      @image = IMAGES.sample random: self.image_randomizer
    end
    
    def apply?
      [true, true, false].sample(random: image_randomizer)
    end
    
    def apply
      return canvas unless apply?
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cheers-0.0.4 lib/cheers/decoration.rb
cheers-0.0.3 lib/cheers/decoration.rb