honeybii 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/honeybii +2 -2
- data/lib/honeybii/ascii_image.rb +1 -1
- data/lib/honeybii/shaded_ascii.rb +34 -0
- data/lib/honeybii.rb +1 -1
- metadata +2 -2
- data/lib/honeybii/shaded_image.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4e80e8eadf36d9a88677631db5f7267b9729db
|
4
|
+
data.tar.gz: 8e965783c2a0be9a7e77279c8e6496ae6e0d11b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc22542706dbb5d825a84430502ba8fc73fb1fff0fab26792bcd84e9cd00aabda122a39d07ba5cdb3024f6e03cb37287f05628bb0819e7f9f924d48532b75d4c
|
7
|
+
data.tar.gz: eb1a1003b964f9d24b454567afa0d765c520eb5d7271aaf1afdb41768ee67e0dc49a4bfb790db2762365b411b7e89d6fe404565e266f5c7a82fe4a569fe2e3c8
|
data/bin/honeybii
CHANGED
@@ -6,7 +6,7 @@ require 'honeybii'
|
|
6
6
|
|
7
7
|
options = {}
|
8
8
|
option_parser = OptionParser.new do |opts|
|
9
|
-
opts.banner = 'Usage: honeybii
|
9
|
+
opts.banner = 'Usage: honeybii [options]'
|
10
10
|
|
11
11
|
opts.on('-i', '--image FILENAME', 'Name of image file to convert (png|gif|jpg)') do |i|
|
12
12
|
options[:image] = i
|
@@ -32,4 +32,4 @@ end
|
|
32
32
|
# defaults
|
33
33
|
options[:pixel_size] = 12 unless options[:pixel_size]
|
34
34
|
|
35
|
-
puts
|
35
|
+
puts ShadedAscii.new(options[:image], options[:pixel_size])
|
data/lib/honeybii/ascii_image.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class ShadedAscii < AsciiImage
|
2
|
+
def initialize(image_filename, point_size = 12)
|
3
|
+
super image_filename, point_size
|
4
|
+
@raw = Magick::ImageList.new(image_filename).first
|
5
|
+
@shades = ['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' ']
|
6
|
+
to_ascii!
|
7
|
+
end
|
8
|
+
|
9
|
+
def grayscale!
|
10
|
+
@raw = @raw.quantize(256, Magick::GRAYColorspace)
|
11
|
+
end
|
12
|
+
|
13
|
+
def pixelate!
|
14
|
+
columns = @raw.columns / @point_size
|
15
|
+
rows = @raw.rows / @point_size
|
16
|
+
@raw = @raw.resize_to_fit(columns, rows)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_ascii!
|
20
|
+
grayscale!
|
21
|
+
pixelate!
|
22
|
+
|
23
|
+
@ascii_array = Array.new(@raw.rows).collect do |row|
|
24
|
+
Array.new(@raw.columns)
|
25
|
+
end
|
26
|
+
|
27
|
+
@raw.each_pixel do |pixel, col, row|
|
28
|
+
index = (((@shades.size - 1) * pixel.intensity).to_f / 65535.to_f).round
|
29
|
+
@ascii_array[row][col] = @shades[index]
|
30
|
+
end
|
31
|
+
|
32
|
+
@ascii = @ascii_array.map { |row| row.join }.join("\n")
|
33
|
+
end
|
34
|
+
end
|
data/lib/honeybii.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'honeybii/ascii_image'
|
2
|
-
require 'honeybii/
|
2
|
+
require 'honeybii/shaded_ascii'
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamey DeOrio
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- bin/honeybii
|
35
35
|
- lib/honeybii.rb
|
36
36
|
- lib/honeybii/ascii_image.rb
|
37
|
-
- lib/honeybii/
|
37
|
+
- lib/honeybii/shaded_ascii.rb
|
38
38
|
homepage: http://honeybii.com
|
39
39
|
licenses:
|
40
40
|
- MIT
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class ShadedImage < AsciiImage
|
2
|
-
def initialize(image_filename, point_size = 12)
|
3
|
-
super image_filename, point_size
|
4
|
-
@raw = Magick::ImageList.new(image_filename).first
|
5
|
-
@shades = ['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' ']
|
6
|
-
end
|
7
|
-
|
8
|
-
def grayscale
|
9
|
-
clone = self.clone
|
10
|
-
clone.raw = clone.raw.quantize(256, Magick::GRAYColorspace)
|
11
|
-
return clone
|
12
|
-
end
|
13
|
-
|
14
|
-
def grayscale!
|
15
|
-
@raw = @raw.quantize(256, Magick::GRAYColorspace)
|
16
|
-
end
|
17
|
-
|
18
|
-
def pixelate
|
19
|
-
columns = @raw.columns / @point_size
|
20
|
-
rows = @raw.rows / @point_size
|
21
|
-
clone = self.clone
|
22
|
-
clone.raw = clone.raw.resize_to_fit(columns, rows)
|
23
|
-
return clone
|
24
|
-
end
|
25
|
-
|
26
|
-
def pixelate!
|
27
|
-
columns = @raw.columns / @point_size
|
28
|
-
rows = @raw.rows / @point_size
|
29
|
-
@raw = @raw.resize_to_fit(columns, rows)
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_ascii
|
33
|
-
clone = self.clone
|
34
|
-
clone.grayscale!
|
35
|
-
clone.pixelate!
|
36
|
-
|
37
|
-
clone.ascii = Array.new(clone.raw.rows).collect do |row|
|
38
|
-
Array.new(clone.raw.columns)
|
39
|
-
end
|
40
|
-
|
41
|
-
clone.raw.each_pixel do |pixel, col, row|
|
42
|
-
index = (((clone.shades.size - 1) * pixel.intensity).to_f / 65535.to_f).round
|
43
|
-
char = clone.shades[index]
|
44
|
-
clone.ascii[row][col] = char
|
45
|
-
end
|
46
|
-
|
47
|
-
return clone
|
48
|
-
end
|
49
|
-
end
|