honeybii 1.1.1 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6adb7f18fd1f8eee84534167a89a3ffb33f12c58
4
- data.tar.gz: 95de630b2da78a75d7d0fe715ca1cc08ec724a4c
3
+ metadata.gz: f8253805c2d75c692318f162548602dc04b51cb4
4
+ data.tar.gz: 2a911a44cb10cf5ec4bdea7838812e26cc84ae17
5
5
  SHA512:
6
- metadata.gz: 9cfc6a6059c163cf5c14e34cfa59764241ad5af0a85ffef79a371318e96108c2f537e5ab2b475e6ee228468984864f2872230eec542d3c7fc7d3f7f9ea7da78d
7
- data.tar.gz: 390e101890b793dc0c208cc359f6ae7f169d4483c1af1d795c2c845f13741ce9b90f289db00576702b1cd05cc20a69e7355eee5e187080308a5f1a099653ae59
6
+ metadata.gz: fe123439446bdefc6d21bf076ca5df9a8ff378dcdfc3cd2d6f80c69c744d36380dfb03c5443291900752f0192b077510219c0d7ce0db0b317bb47749aeb7a59f
7
+ data.tar.gz: a7ea69fbe695a100f4a1f76a687d704db188778e6f0400588a9190c982afcf1649f1f963656e369f3079a09fb3895f48238edbbfde9632e943053a645aa7a359
@@ -2,13 +2,12 @@ require 'rmagick'
2
2
 
3
3
  class AsciiImage
4
4
  attr_accessor :raw
5
- attr_accessor :shades
6
5
  attr_accessor :ascii
7
6
 
8
7
  def initialize(image_filename, point_size)
9
- @raw = Magick::ImageList.new(image_filename)[0]
8
+ @raw = Magick::ImageList.new(image_filename).first
10
9
  @point_size = point_size
11
- @ascii = Array.new
10
+ @ascii = ''
12
11
  end
13
12
 
14
13
  def to_s
@@ -1,8 +1,8 @@
1
+ SHADES = ['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' ']
2
+
1
3
  class ShadedAscii < AsciiImage
2
4
  def initialize(image_filename, point_size = 12)
3
5
  super image_filename, point_size
4
- @raw = Magick::ImageList.new(image_filename).first
5
- @shades = ['@', '%', '8', '#', '$', 'V', 'Y', 'x', '*', '=', '+', ':', '~', '-', '.', ' ']
6
6
  to_ascii!
7
7
  end
8
8
 
@@ -12,23 +12,23 @@ class ShadedAscii < AsciiImage
12
12
 
13
13
  def pixelate!
14
14
  columns = @raw.columns / @point_size
15
- rows = @raw.rows / @point_size
16
- @raw = @raw.resize_to_fit(columns, rows)
15
+ rows = @raw.rows / (@point_size * 2)
16
+ @raw.resize!(columns, rows)
17
17
  end
18
18
 
19
19
  def to_ascii!
20
20
  grayscale!
21
21
  pixelate!
22
22
 
23
- @ascii_array = Array.new(@raw.rows).collect do |row|
23
+ ascii_array = Array.new(@raw.rows).collect do |row|
24
24
  Array.new(@raw.columns)
25
25
  end
26
26
 
27
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]
28
+ index = (((SHADES.size - 1) * pixel.intensity).to_f / 65535.to_f).round
29
+ ascii_array[row][col] = SHADES[index]
30
30
  end
31
31
 
32
- @ascii = @ascii_array.map { |row| row.join }.join("\n")
32
+ @ascii = ascii_array.map { |row| row.join }.join("\n")
33
33
  end
34
34
  end
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.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamey DeOrio