honeybii 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/honeybii +13 -2
- data/lib/honeybii/shaded_ascii.rb +17 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10bc5196f06fe471586df6e35a69c5fff47b2b16
|
4
|
+
data.tar.gz: 1719cb9b941e8dc857bb840c1c5643cc33f7ec48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c55d049c203be4b48ef84b45641ead8b6d582e5abf8631c99b0ed40075d39eb92ab90b670fe68be16b32769a79ef6af553623b93eb2e5066a47a6e3a531460
|
7
|
+
data.tar.gz: dbe37caa9cf0e4c572695ff72031d443eacc6468e09f6196194f18f27ccf883f8bdc661ad63abc1a764e4094f3fbbcc6de103d5767d7e80fa064df00fe78958c
|
data/bin/honeybii
CHANGED
@@ -12,9 +12,14 @@ option_parser = OptionParser.new do |opts|
|
|
12
12
|
options[:image] = i
|
13
13
|
end
|
14
14
|
|
15
|
-
opts.on('-s', '--pixel-size PIXELS', Integer, 'Size of image chunks to process into ascii (smaller => more detail)') do |s|
|
15
|
+
opts.on('-s', '--pixel-size PIXELS', Integer, 'Size of image chunks to process into ascii (smaller => more detail) [default: 12]') do |s|
|
16
16
|
options[:pixel_size] = s
|
17
17
|
end
|
18
|
+
|
19
|
+
gradients = ShadedAscii.gradients.map.with_index { |g, i| {i => g.join} }
|
20
|
+
opts.on('-g', '--gradient N', Integer, "Gradient level (the lower the denser) [default: 0] #{gradients}") do |g|
|
21
|
+
options[:gradient_level] = g
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
option_parser.parse!
|
@@ -31,5 +36,11 @@ end
|
|
31
36
|
|
32
37
|
# defaults
|
33
38
|
options[:pixel_size] = 12 unless options[:pixel_size]
|
39
|
+
options[:gradient_level] = 0 unless options[:gradient_level]
|
40
|
+
|
41
|
+
# validations
|
42
|
+
unless options[:gradient_level].between? 0, ShadedAscii.gradients.size - 1
|
43
|
+
raise ArgumentError, "Please choose a gradient level between 0 and #{ShadedAscii.gradients.size - 1}"
|
44
|
+
end
|
34
45
|
|
35
|
-
puts ShadedAscii.new(options[:image], options[:pixel_size])
|
46
|
+
puts ShadedAscii.new(options[:image], options[:pixel_size], gradient_level: options[:gradient_level])
|
@@ -1,8 +1,20 @@
|
|
1
|
-
SHADES = ['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' ']
|
2
|
-
|
3
1
|
class ShadedAscii < AsciiImage
|
4
|
-
|
2
|
+
class << self
|
3
|
+
attr_accessor :gradients
|
4
|
+
end
|
5
|
+
|
6
|
+
@gradients = [
|
7
|
+
['M', 'N', 'H', 'K', 'b', 'X', '6', 'Y', 'j', 'i', '+', '!', ':', '\'', '.', ' '],
|
8
|
+
['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' '],
|
9
|
+
['M', 'H', 'b', '6', 'j', '+', ':', ' '],
|
10
|
+
['@', '8', 'O', 'o', ':', '.', ' '],
|
11
|
+
['8', 'O', 'o', ':', '.', ' '],
|
12
|
+
['#', '+', ':', ' '],
|
13
|
+
]
|
14
|
+
|
15
|
+
def initialize(image_filename, point_size = 12, gradient_level: 0)
|
5
16
|
super image_filename, point_size
|
17
|
+
@gradient = ShadedAscii.gradients[gradient_level]
|
6
18
|
to_ascii!
|
7
19
|
end
|
8
20
|
|
@@ -25,8 +37,8 @@ class ShadedAscii < AsciiImage
|
|
25
37
|
end
|
26
38
|
|
27
39
|
@raw.each_pixel do |pixel, col, row|
|
28
|
-
index = (((
|
29
|
-
ascii_array[row][col] =
|
40
|
+
index = (((@gradient.size - 1) * pixel.intensity).to_f / 65535.to_f).round
|
41
|
+
ascii_array[row][col] = @gradient[index]
|
30
42
|
end
|
31
43
|
|
32
44
|
@ascii = ascii_array.map { |row| row.join }.join("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeybii
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamey DeOrio
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: rmagick
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
description: A command-line image to ascii conversion tool
|
28
28
|
email: jamey@jameydeorio.com
|
29
29
|
executables:
|