Class: GeoPattern::BackgroundGenerators::SolidGenerator

Inherits:
Object
  • Object
show all
Includes:
Roles::NamedGenerator
Defined in:
lib/geo_pattern/background_generators/solid_generator.rb

Overview

Generating a solid background

Instance Method Summary collapse

Methods included from Roles::NamedGenerator

#name, #name?

Constructor Details

#initialize(seed, preset) ⇒ SolidGenerator

New generator

Parameters:

  • seed (Seed)

    The seed used during generation the background

  • preset (ColorPreset)

    A preset of values which are used during generating the background


21
22
23
24
# File 'lib/geo_pattern/background_generators/solid_generator.rb', line 21

def initialize(seed, preset)
  @color  = color_for(seed, preset)
  @preset = preset
end

Instance Method Details

#generate(pattern) ⇒ Object

Generate the background for pattern

Parameters:

  • pattern (#background=)

    The pattern for which the background should be generated


30
31
32
33
34
# File 'lib/geo_pattern/background_generators/solid_generator.rb', line 30

def generate(pattern)
  pattern.background = Background.new(image: generate_background, preset: preset, color: color, generator: self.class)

  self
end