fictionArt 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -0
- data/images/ash_pokemon.jpg +0 -0
- data/images/batman.jpg +0 -0
- data/images/baymax.jpg +0 -0
- data/images/bulbasaur.jpg +0 -0
- data/images/captain_america.jpg +0 -0
- data/images/charizard.jpg +0 -0
- data/images/charmander.jpg +0 -0
- data/images/doctor_strange.jpg +0 -0
- data/images/doofenshmirtz.jpg +0 -0
- data/images/doraemon.jpg +0 -0
- data/images/ferb.jpg +0 -0
- data/images/gian.jpg +0 -0
- data/images/goku.jpg +0 -0
- data/images/hawkeye.jpg +0 -0
- data/images/hulk.jpg +0 -0
- data/images/humungousaur.jpg +0 -0
- data/images/ironman.jpg +0 -0
- data/images/joker.jpg +0 -0
- data/images/krrish.jpg +0 -0
- data/images/nobita.jpg +0 -0
- data/images/oggy.jpg +0 -0
- data/images/perry.jpg +0 -0
- data/images/phineas.jpg +0 -0
- data/images/pikachu.jpg +0 -0
- data/images/shizuka.jpg +0 -0
- data/images/spiderman.jpg +0 -0
- data/images/squirtle.jpg +0 -0
- data/images/suneo.jpg +0 -0
- data/images/superman.jpg +0 -0
- data/images/thanos.jpg +0 -0
- data/images/thor.jpg +0 -0
- data/images/tom_and_jerry.jpg +0 -0
- data/images/vegeta.jpg +0 -0
- data/images/vision.jpg +0 -0
- data/lib/fictionArt.rb +123 -0
- metadata +37 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d357bc789da33eb33dcd917923c64003638d85eefde0946c1784f499ab81b30d
|
4
|
+
data.tar.gz: b84d0d52a4c3b2b63884452164575da8778f182c27d249b1bbeed9db3234fcf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18617faceab3509c2bb5e6914b1e51c6211d786ee730738ea5ab4910814995f8eb8cb5c23c2484c1f73a99438c1b2c8e7b4620d94a3bf3c0641072ee1de45e35
|
7
|
+
data.tar.gz: b9816365b2d7066c629be966e9c90f14b08da5c6e7954fa8de77a66ac49707180d8dc67c93173e1ee69ed98de70b9c32c4965fe6e2f71a9028ea04797fe4f928
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# fictionArt
|
2
|
+
A command line tool written in ruby that displays ascii art of famous animated fictional characters.
|
3
|
+
|
4
|
+
## Requirements
|
5
|
+
```
|
6
|
+
=> Homebrew (for macOS)
|
7
|
+
=> ruby version >= 1.8.6 (pre-installed on macOS, can be easily installed on linux)
|
8
|
+
=> ImageMagick library (will be installed in next section)
|
9
|
+
```
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
### Linux
|
14
|
+
|
15
|
+
**Run the following commands after (without the '$' sign) ruby has been installed succesfully**
|
16
|
+
```
|
17
|
+
$ echo "export GEM_HOME=$HOME/.gem" >> ~/.bashrc
|
18
|
+
$ echo "export GEM_PATH=$HOME/.gem" >> ~/.bashrc
|
19
|
+
$ echo "export PATH=$PATH:~/.gem/bin" >> ~/.bashrc
|
20
|
+
$ source ~/.bashrc
|
21
|
+
$ sudo apt-get install imagemagick libmagickwand-dev
|
22
|
+
$ gem install fictionArt
|
23
|
+
```
|
24
|
+
|
25
|
+
### MacOS
|
26
|
+
|
27
|
+
**Run the following commands (without the '$' sign) after ruby has been installed succesfully**
|
28
|
+
```
|
29
|
+
$ echo "export GEM_HOME=$HOME/.gem" >> ~/.bash_profile
|
30
|
+
$ echo "export GEM_PATH=$HOME/.gem" >> ~/.bash_profile
|
31
|
+
$ echo "export PATH=$PATH:~/.gem/bin" >> ~/.bash_profile
|
32
|
+
$ source ~/.bash_profile
|
33
|
+
$ brew install imagemagick@6 && brew link imagemagick@6 --force
|
34
|
+
$ gem install fictionArt
|
35
|
+
```
|
36
|
+
|
37
|
+
### Usage
|
38
|
+
**Example**
|
39
|
+
```
|
40
|
+
$ fictionArt ironman
|
41
|
+
```
|
42
|
+
**Output**
|
43
|
+
![image](https://github.com/vaithak/fictionArt/blob/master/example_image.png)
|
44
|
+
|
45
|
+
### Help
|
46
|
+
```
|
47
|
+
$ fictionArt -h
|
48
|
+
```
|
Binary file
|
data/images/batman.jpg
ADDED
Binary file
|
data/images/baymax.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/images/doraemon.jpg
ADDED
Binary file
|
data/images/ferb.jpg
ADDED
Binary file
|
data/images/gian.jpg
ADDED
Binary file
|
data/images/goku.jpg
ADDED
Binary file
|
data/images/hawkeye.jpg
ADDED
Binary file
|
data/images/hulk.jpg
ADDED
Binary file
|
Binary file
|
data/images/ironman.jpg
ADDED
Binary file
|
data/images/joker.jpg
ADDED
Binary file
|
data/images/krrish.jpg
ADDED
Binary file
|
data/images/nobita.jpg
ADDED
Binary file
|
data/images/oggy.jpg
ADDED
Binary file
|
data/images/perry.jpg
ADDED
Binary file
|
data/images/phineas.jpg
ADDED
Binary file
|
data/images/pikachu.jpg
ADDED
Binary file
|
data/images/shizuka.jpg
ADDED
Binary file
|
Binary file
|
data/images/squirtle.jpg
ADDED
Binary file
|
data/images/suneo.jpg
ADDED
Binary file
|
data/images/superman.jpg
ADDED
Binary file
|
data/images/thanos.jpg
ADDED
Binary file
|
data/images/thor.jpg
ADDED
Binary file
|
Binary file
|
data/images/vegeta.jpg
ADDED
Binary file
|
data/images/vision.jpg
ADDED
Binary file
|
data/lib/fictionArt.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'RMagick'
|
2
|
+
require 'uri'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'rainbow'
|
5
|
+
require 'rainbow/ext/string'
|
6
|
+
|
7
|
+
class FictionArt
|
8
|
+
|
9
|
+
attr_accessor :image_chars
|
10
|
+
attr_accessor :status # for tests
|
11
|
+
|
12
|
+
# Constructor function of FictionArt class
|
13
|
+
def initialize(text = "nothing")
|
14
|
+
|
15
|
+
@image_chars ||= ' .~:+=o*x^%#@'.chars.to_a
|
16
|
+
check = Dir.glob("#{__dir__}/../images/#{text}.jpg")
|
17
|
+
|
18
|
+
if check.length == 0
|
19
|
+
if text == "nothing"
|
20
|
+
@status = false # for tests
|
21
|
+
elsif text.nil?
|
22
|
+
@status = false # for tests
|
23
|
+
abort("Nothing inputted")
|
24
|
+
else
|
25
|
+
@status = false # for tests
|
26
|
+
puts
|
27
|
+
check_possible(text)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
open(check[0]) { |file| @data = file.read }
|
31
|
+
@status = true # for tests
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# Create ascii Art of given fictional character
|
38
|
+
def createAscii(options = {})
|
39
|
+
if @status == true
|
40
|
+
options = {"width" => 90, "color" => true}.merge(options)
|
41
|
+
img = Magick::Image.from_blob(@data).first
|
42
|
+
width = options["width"]
|
43
|
+
scale = (width.to_f / img.columns)
|
44
|
+
|
45
|
+
height = ((img.rows * scale) / 2).to_i
|
46
|
+
# puts height
|
47
|
+
if height >= 100
|
48
|
+
height = 80
|
49
|
+
end
|
50
|
+
|
51
|
+
border = "+#{'-' * width}+\n"
|
52
|
+
output = border.dup
|
53
|
+
|
54
|
+
img.resize!(width, height)
|
55
|
+
color_image = img.dup if options["color"]
|
56
|
+
img = img.quantize(@image_chars.length, Magick::GRAYColorspace).normalize
|
57
|
+
quantum_calc = Magick::QuantumRange / (@image_chars.length - 1)
|
58
|
+
|
59
|
+
|
60
|
+
img.view(0, 0, width, height) do |view|
|
61
|
+
|
62
|
+
height.times do |i|
|
63
|
+
|
64
|
+
output << '|'
|
65
|
+
width.times do |j|
|
66
|
+
|
67
|
+
character = @image_chars[view[i][j].red/quantum_calc]
|
68
|
+
|
69
|
+
if options["color"]
|
70
|
+
pix = color_image.pixel_color(j,i)
|
71
|
+
character = character.color(unified_rgb_value(pix.red), unified_rgb_value(pix.green), unified_rgb_value(pix.blue))
|
72
|
+
end
|
73
|
+
|
74
|
+
output << character
|
75
|
+
end
|
76
|
+
|
77
|
+
output << "|\n"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
output << border
|
83
|
+
return output
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# Converting into unified rgb value from 0-255
|
89
|
+
def unified_rgb_value(number)
|
90
|
+
if defined?(Magick::QuantumDepth)
|
91
|
+
return (Magick::QuantumDepth == 16) ? (number / 256) : number
|
92
|
+
else
|
93
|
+
return (Magick::QuantumRange == 65535) ? (number / 256) : number
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
# Listing all currently possible characters
|
99
|
+
def list_all
|
100
|
+
list = Dir.glob("#{__dir__}/../images/*.jpg")
|
101
|
+
list.each do |character|
|
102
|
+
puts character[/.*images\/(.*).jpg/,1]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
# Checking matching characters from character inputted
|
108
|
+
def check_possible(text)
|
109
|
+
puts "Possible Characters:"
|
110
|
+
list = Dir.glob("#{__dir__}/../images/*.jpg")
|
111
|
+
|
112
|
+
list.each do |character|
|
113
|
+
character = character[/.*images\/(.*).jpg/,1]
|
114
|
+
if character.downcase.include? text.downcase
|
115
|
+
puts character
|
116
|
+
elsif text.downcase.include? character.downcase
|
117
|
+
puts character
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fictionArt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vaibhav Thakkar
|
@@ -45,7 +45,43 @@ executables:
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- README.md
|
48
49
|
- bin/fictionArt
|
50
|
+
- images/ash_pokemon.jpg
|
51
|
+
- images/batman.jpg
|
52
|
+
- images/baymax.jpg
|
53
|
+
- images/bulbasaur.jpg
|
54
|
+
- images/captain_america.jpg
|
55
|
+
- images/charizard.jpg
|
56
|
+
- images/charmander.jpg
|
57
|
+
- images/doctor_strange.jpg
|
58
|
+
- images/doofenshmirtz.jpg
|
59
|
+
- images/doraemon.jpg
|
60
|
+
- images/ferb.jpg
|
61
|
+
- images/gian.jpg
|
62
|
+
- images/goku.jpg
|
63
|
+
- images/hawkeye.jpg
|
64
|
+
- images/hulk.jpg
|
65
|
+
- images/humungousaur.jpg
|
66
|
+
- images/ironman.jpg
|
67
|
+
- images/joker.jpg
|
68
|
+
- images/krrish.jpg
|
69
|
+
- images/nobita.jpg
|
70
|
+
- images/oggy.jpg
|
71
|
+
- images/perry.jpg
|
72
|
+
- images/phineas.jpg
|
73
|
+
- images/pikachu.jpg
|
74
|
+
- images/shizuka.jpg
|
75
|
+
- images/spiderman.jpg
|
76
|
+
- images/squirtle.jpg
|
77
|
+
- images/suneo.jpg
|
78
|
+
- images/superman.jpg
|
79
|
+
- images/thanos.jpg
|
80
|
+
- images/thor.jpg
|
81
|
+
- images/tom_and_jerry.jpg
|
82
|
+
- images/vegeta.jpg
|
83
|
+
- images/vision.jpg
|
84
|
+
- lib/fictionArt.rb
|
49
85
|
homepage: https://github.com/vaithak/fictionArt
|
50
86
|
licenses:
|
51
87
|
- MIT
|