Class: Algoheader::SvgGenerator

Inherits:
ServiceObject show all
Defined in:
lib/algoheader/svg_generator.rb

Overview

SvgGenerator

Author

Dick Davis

Copyright

Copyright 2021 Dick Davis

License

GNU Public License 3

Generates SVGs by providing randomized input to algorithm.

Constant Summary collapse

SYMBOLS =
['/', '|', '\\', '-', '+', 'x', 'o', "\#", '.'].freeze
WIDTHS =
[0.75, 1.0, 1.5].freeze
LINECAPS =
%w[butt round square].freeze
OPACITIES =
[0.8, 0.9, 1.0].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ServiceObject

call

Constructor Details

#initialize(fill_colors:, stroke_colors:) ⇒ SvgGenerator

rubocop:disable Lint/MissingSuper



40
41
42
43
# File 'lib/algoheader/svg_generator.rb', line 40

def initialize(fill_colors:, stroke_colors:)
  @fill_colors = fill_colors
  @stroke_colors = stroke_colors
end

Instance Attribute Details

#fill_colorsObject (readonly)

Returns the value of attribute fill_colors.



37
38
39
# File 'lib/algoheader/svg_generator.rb', line 37

def fill_colors
  @fill_colors
end

#stroke_colorsObject (readonly)

Returns the value of attribute stroke_colors.



37
38
39
# File 'lib/algoheader/svg_generator.rb', line 37

def stroke_colors
  @stroke_colors
end

Instance Method Details

#callObject

rubocop:enable Lint/MissingSuper



46
47
48
49
50
51
# File 'lib/algoheader/svg_generator.rb', line 46

def call
  ascii = AsciiToSvg.example_string(random_symbol_sample, 80)
  AsciiToSvg.from_string(ascii, 16, **options)
rescue ZeroDivisionError
  retry
end