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 +4 -4
- data/.gitignore +5 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/lib/artascii/version.rb +1 -1
- data/lib/artascii.rb +17 -5
- data/sample/Test.rb +5 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db43e7fe9ff4a8e483130930f1a30cfdf6399cda399025e735d4ef27361a08ff
|
4
|
+
data.tar.gz: 66d3cd6b5248e0485c962862c47a59868ede2b5208a46a7d631aa93c33502515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 832eda1230b08a3787cde81801b2b921d1a22faf016ebd151816f29e369d982d6c9f61b89ed7b0747ef1b046366307c64577c4fd0a2232139b18d78df0908a72
|
7
|
+
data.tar.gz: f3a0b77f316e6125fc88d828d3c6a5172ff3035849271d1e840a1769abee9ba9936a2a50092a42e72fb4fc050a470d3c72da84272470915204a8b29cf78caeeb
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
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 '
|
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
|
19
|
+
$ gem install artascii
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
data/lib/artascii/version.rb
CHANGED
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
|
46
|
-
|
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
|
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.
|
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-
|
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.
|
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: []
|