artascii 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53328578d10edd0a41fd33162905ef8209325999d45da9669d5fc62d613b0ee3
4
- data.tar.gz: 7cdc17465d0a28fe9986b70a90365ac5ba0a654cfbe7309fbc550a58d9bffa45
3
+ metadata.gz: db43e7fe9ff4a8e483130930f1a30cfdf6399cda399025e735d4ef27361a08ff
4
+ data.tar.gz: 66d3cd6b5248e0485c962862c47a59868ede2b5208a46a7d631aa93c33502515
5
5
  SHA512:
6
- metadata.gz: 494d59ec381f9090bb7d8d10f7f8cef76a5b8048de1dfc7bac41c54a8451e2a0a37b01aab836b1763ed73ef3324b41220f7d1d45443570de0315e640820182ae
7
- data.tar.gz: 8d5227126c975ea407302ded58a70099c414c5398d8b198d44df12ad3eebc9cc329071220636f9b8d6ee29a511f8e1fca3b14fec7511b2c3eb7342a139688c00
6
+ metadata.gz: 832eda1230b08a3787cde81801b2b921d1a22faf016ebd151816f29e369d982d6c9f61b89ed7b0747ef1b046366307c64577c4fd0a2232139b18d78df0908a72
7
+ data.tar.gz: f3a0b77f316e6125fc88d828d3c6a5172ff3035849271d1e840a1769abee9ba9936a2a50092a42e72fb4fc050a470d3c72da84272470915204a8b29cf78caeeb
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ /*.txt
2
+ /vendor/
1
3
  /.bundle/
2
4
  /.yardoc
3
5
  /_yardoc/
@@ -9,3 +11,6 @@
9
11
 
10
12
  # rspec failure tracking
11
13
  .rspec_status
14
+
15
+ # Ruby version set by rbenv
16
+ .ruby-version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artascii (0.1.0)
4
+ artascii (0.2.0)
5
5
  mini_magick (~> 4.11)
6
6
 
7
7
  GEM
@@ -54,4 +54,4 @@ DEPENDENCIES
54
54
  rubocop (~> 0.80)
55
55
 
56
56
  BUNDLED WITH
57
- 2.1.4
57
+ 2.2.31
data/README.md CHANGED
@@ -7,7 +7,7 @@ Generate ASCII art from images.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'asciiart'
10
+ gem 'artascii'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install asciigen
19
+ $ gem install artascii
20
20
 
21
21
  ## Usage
22
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Artascii
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/artascii.rb CHANGED
@@ -13,8 +13,7 @@ module Artascii
13
13
  @image = MiniMagick::Image.open(path)
14
14
  @height = @image.height
15
15
  @width = @image.width
16
- @image.resize resize_percent
17
-
16
+ @matrix = @image.resize resize_percent
18
17
  self
19
18
  end
20
19
 
@@ -39,11 +38,24 @@ module Artascii
39
38
  line.each { |pixel| line_mx.append(to_char(pixel)) }
40
39
  ascii_mx.append(line_mx)
41
40
  end
42
- print_mx(ascii_mx)
41
+ # print_mx(ascii_mx)
42
+ ascii_mx
43
+ end
44
+
45
+ def modify_ascii_mx
46
+ ascii_mx = Array.new
47
+ @matrix.each do |line|
48
+ line_mx = Array.new
49
+ line.each { |pixel| yield }
50
+ ascii_mx.append(line_mx)
51
+ end
52
+ ascii_mx
43
53
  end
44
54
 
45
- def print_mx(matrix)
46
- matrix.each { |line| puts line.join() }
55
+ def print_to_file(matrix, path=nil)
56
+ File.open(path, "w") do |f|
57
+ matrix.each { |line| f.puts line.join() + '\n'}
58
+ end
47
59
  end
48
60
 
49
61
  def to_char(brightness)
data/sample/Test.rb CHANGED
@@ -2,7 +2,7 @@ require_relative "../lib/artascii"
2
2
  require "mini_magick"
3
3
 
4
4
  path = "/home/lovepreet/Downloads/daisy.jpg"
5
- image_mx = Artascii::Image.new(path, "80x80")
5
+ image_mx = Artascii::Image.new(path)
6
6
  puts "Successfully Loaded Image!"
7
7
  puts "Image Size: #{image_mx.height} x #{image_mx.width}"
8
8
 
@@ -18,4 +18,7 @@ puts "Using average method"
18
18
  bright_pixels = image_mx.get_brightness_mx(pixels)
19
19
  puts "Brightness Pixel Matrix Size: #{bright_pixels.length} x #{bright_pixels[0].length}"
20
20
 
21
- image_mx.get_ascii_mx(bright_pixels)
21
+ mx = image_mx.get_ascii_mx(bright_pixels)
22
+ image_mx.print_to_file(mx, "matrix.txt")
23
+
24
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artascii
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovepreet Singh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.11'
27
- description:
27
+ description:
28
28
  email:
29
29
  - Lovepreetkaul23@gmail.com
30
30
  executables: []
@@ -53,7 +53,7 @@ metadata:
53
53
  homepage_uri: https://github.com/lovepreetkaul/artascii
54
54
  source_code_uri: https://github.com/lovepreetkaul/artascii
55
55
  changelog_uri: https://github.com/lovepreetkaul/artascii/CHANGELOG.md
56
- post_install_message:
56
+ post_install_message:
57
57
  rdoc_options: []
58
58
  require_paths:
59
59
  - lib
@@ -68,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  requirements: []
71
- rubygems_version: 3.2.16
72
- signing_key:
71
+ rubygems_version: 3.1.6
72
+ signing_key:
73
73
  specification_version: 4
74
74
  summary: Project to generate Ascii art from images.
75
75
  test_files: []