Class: IOSIconGenerator::CLI::Commands::Build::Icon

Inherits:
Hanami::CLI::Command
  • Object
show all
Defined in:
lib/ios_icon_generator/cli/commands/mask.rb

Instance Method Summary collapse

Instance Method Details

#call(appiconset_path:, output_path:, **options) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ios_icon_generator/cli/commands/mask.rb', line 50

def call(appiconset_path:, output_path:, **options)
  raise "#{'ImageMagick'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install imagemagick'.blue.bold.underlined}" unless Library.which('magick')

  raise 'There is no App icon set at the path specified.' unless Dir.exist?(appiconset_path)

  progress_bar = ProgressBar.create(total: nil)
  parallel_processes = options.fetch(:parallel_processes).to_i
  parallel_processes = nil if parallel_processes == -1
  Helpers.mask_icon(
    appiconset_path: appiconset_path,
    output_folder: output_path,
    mask: {
      background_color: options.fetch(:background_color),
      stroke_color: options.fetch(:stroke_color),
      stroke_width_offset: options.fetch(:stroke_width_offset)&.to_f,
      suffix: options.fetch(:suffix),
      symbol: options.fetch(:symbol),
      symbol_color: options.fetch(:symbol_color),
      font: options.fetch(:font),
      file: options[:file],
      x_size_ratio: options.fetch(:x_size_ratio)&.to_f,
      y_size_ratio: options.fetch(:y_size_ratio)&.to_f,
      size_offset: options.fetch(:size_offset)&.to_f,
      x_offset: options.fetch(:x_offset)&.to_f,
      y_offset: options.fetch(:y_offset)&.to_f,
      shape: options.fetch(:mask_shape)&.to_sym,
    },
    parallel_processes: parallel_processes,
    progress: lambda do |progress, total|
      progress_bar.total = total unless progress_bar.total
      progress_bar.increment if progress
    end
  )
  puts 'Completed!'.green
end