Skip to content

Commit

Permalink
Merge pull request #7 from Fueled/misc-updates
Browse files Browse the repository at this point in the history
Update default parameters to make prettier icons, and make JSON pretty-generated
  • Loading branch information
stephanecopin authored Feb 21, 2019
2 parents c3fc530 + 902ba46 commit 8389c67
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/ios_icon_generator/cli/commands/mask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Icon < Hanami::CLI::Command
option :symbol_color, default: '#7F0000', desc: 'The color of the symbol to use to generate the mask.'
option :font, default: 'Helvetica', desc: 'The font to use to generate the symbol.'
option :file, default: nil, desc: 'The path to an image representing the symbol to use to generate the mask.'
option :x_size_ratio, type: :float, default: 0.46, desc: 'The x offset of the size of the mask.'
option :y_size_ratio, type: :float, default: 0.46, desc: 'The y offset of the size of the mask.'
option :x_size_ratio, type: :float, default: 0.54, desc: 'The x offset of the size of the mask.'
option :y_size_ratio, type: :float, default: 0.54, desc: 'The y offset of the size of the mask.'
option :size_offset, type: :float, default: 0.12, desc: 'The size offset to use when applying the symbol. 0.0 means it\'s scale to the full image, 1.0 means the symbol has the full size of the logo.'
option :x_offset, type: :float, default: 0.11, desc: 'The x offset to use when applying the symbol. 0.0 means bottom, 1.0 means top.'
option :y_offset, type: :float, default: 0.11, desc: 'The y offset to use when applying the symbol. 0.0 means left, 1.0 means top.'
Expand Down
4 changes: 2 additions & 2 deletions lib/ios_icon_generator/cli/commands/stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class Stub < Hanami::CLI::Command
option :font, default: 'Helvetica', desc: 'The font to use to generate the symbol.'
option :symbol_color, default: '#7F0000', desc: 'The color of the symbol to use to generate the mask.'
option :stroke_color, default: '#000000', desc: 'The stroke color of the mask'
option :stroke_width_offset, type: :float, default: 0.1, desc: 'The width of the stroke used when generating the symbol.'
option :stroke_width_offset, type: :float, default: 0.0, desc: 'The width of the stroke used when generating the symbol.'
option :size_offset, type: :float, default: 0.5, desc: 'The point size used for the symbol, relative to the height of the icon. Values over 0.5 are not recommended.'
option :x_offset, type: :float, default: 0.0, desc: 'The x offset to use when applying the symbol. 0.0 means bottom, 1.0 means top.'
option :y_offset, type: :float, default: 0.0, desc: 'The y offset to use when applying the symbol. 0.0 means left, 1.0 means top.'
option :y_offset, type: :float, default: -0.05, desc: 'The y offset to use when applying the symbol. 0.0 means left, 1.0 means top.'
option :type, type: :array, default: %w[iphone], desc: 'Which target to generate the icons for. Can be "iphone", "ipad", "watch", "mac" or "carplay" or a combination of any of them, or "imessage"'
option :parallel_processes, type: :integer, default: -1, desc: 'Number of processes to use to process the files. Defaults to -1, meaning the number of cores the machine. \
Set to 0 to disable parallel processing.'
Expand Down
2 changes: 1 addition & 1 deletion lib/ios_icon_generator/helpers/generate_icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def self.generate_icon(icon_path:, output_folder:, types:, parallel_processes: n
},
}

File.write(File.join(appiconset_path, 'Contents.json'), JSON.generate(contents_json))
File.write(File.join(appiconset_path, 'Contents.json'), JSON.pretty_generate(contents_json))

progress&.call(total - 1, total)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/ios_icon_generator/helpers/mask_icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def self.mask_icon(
symbol: 'b',
symbol_color: '#7F0000',
font: 'Helvetica',
x_size_ratio: 0.5478515625,
y_size_ratio: 0.5478515625,
x_size_ratio: 0.54,
y_size_ratio: 0.54,
size_offset: 0.0,
x_offset: 0.0,
y_offset: 0.0,
Expand Down Expand Up @@ -77,7 +77,7 @@ def self.mask_icon(
draw_shape =
case mask[:shape]
when :triangle
"-draw \"polyline 0,#{mask_size_height} 0,#{height} #{width - mask_size_width},#{height}\""
"-draw \"polyline -#{width},#{height - mask_size_height} 0,#{height - mask_size_height} #{mask_size_width},#{height} #{mask_size_width},#{height * 2.0} -#{width},#{height * 2.0}\""
when :square
"-draw \"rectangle -#{width},#{height * 2.0} #{mask_size_height},#{width - mask_size_width}\""
else
Expand All @@ -95,7 +95,7 @@ def self.mask_icon(
image['filename'] = icon_output
end

File.write(File.join(output_folder, 'Contents.json'), JSON.generate(json_content))
File.write(File.join(output_folder, 'Contents.json'), JSON.pretty_generate(json_content))
end
end
end

0 comments on commit 8389c67

Please sign in to comment.