Skip to content

Commit

Permalink
Change gradient_level to gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamey J. DeOrio committed Apr 13, 2014
1 parent f512401 commit 5e08c3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions bin/honeybii
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ option_parser = OptionParser.new do |opts|

gradients = ShadedAscii.gradients.map.with_index { |g, i| {i => g.join} }
opts.on('-g', '--gradient N', Integer, "Gradient characters [default: 0] #{gradients}") do |g|
options[:gradient_level] = g
options[:gradient] = g
end

opts.on('-o', '--one-to-one', "One-to-one shading, as opposed to relative") do |o|
Expand All @@ -35,12 +35,12 @@ end

# defaults
options[:pixel_size] = 12 unless options[:pixel_size]
options[:gradient_level] = 0 unless options[:gradient_level]
options[:gradient] = 0 unless options[:gradient]
options[:style] = 'relative' unless options[:style]

# validations
unless options[:gradient_level].between? 0, ShadedAscii.gradients.size - 1
raise ArgumentError, "Please choose a gradient level between 0 and #{ShadedAscii.gradients.size - 1}"
unless options[:gradient].between? 0, ShadedAscii.gradients.size - 1
raise ArgumentError, "Please choose a gradient between 0 and #{ShadedAscii.gradients.size - 1}"
end

puts ShadedAscii.new(image, options[:pixel_size], gradient_level: options[:gradient_level], style: options[:style])
puts ShadedAscii.new(image, options[:pixel_size], gradient: options[:gradient], style: options[:style])
4 changes: 2 additions & 2 deletions lib/honeybii/shaded_ascii.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class << self
['#', '+', ':', ' '],
]

def initialize(image_filename, point_size = 12, gradient_level: 0, style: 'one_to_one')
def initialize(image_filename, point_size = 12, gradient: 0, style: 'one_to_one')
super image_filename, point_size
@gradient = ShadedAscii.gradients[gradient_level]
@gradient = ShadedAscii.gradients[gradient]
@style = style
to_ascii!
end
Expand Down

0 comments on commit 5e08c3a

Please sign in to comment.