Class: GeoPattern::StructureGenerators::BaseGenerator

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

Instance Method Summary collapse

Methods included from Roles::NamedGenerator

#name, #name?

Constructor Details

#initialize(seed, preset, svg = SvgImage.new) ⇒ BaseGenerator


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/geo_pattern/structure_generators/base_generator.rb', line 13

def initialize(seed, preset, svg = SvgImage.new)
  @svg    = svg
  @seed   = seed
  @preset = preset

  @fill_color_dark  = @preset.fill_color_dark
  @fill_color_light = @preset.fill_color_light
  @stroke_color     = @preset.stroke_color
  @stroke_opacity   = @preset.stroke_opacity
  @opacity_min      = @preset.opacity_min
  @opacity_max      = @preset.opacity_max

  @height = 100
  @width  = 100

  after_initialize
end

Instance Method Details

#generate(pattern) ⇒ Object


31
32
33
34
35
36
37
38
# File 'lib/geo_pattern/structure_generators/base_generator.rb', line 31

def generate(pattern)
  pattern.structure = Structure.new(image: svg_image, preset: preset, generator: self.class, name: name)

  pattern.height    = height
  pattern.width     = width

  self
end