fictionArt 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +1 -36
- 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 +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cee34142b88b8607296f7118a43b29379f8355bf175642c61f6641d5a21603e
|
4
|
+
data.tar.gz: e764306950aa1514f17d198fa5bd3fe15e11f227098cdc1905c2fa15ca9752bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ab3239920659970390f4f73c886ea3267cfabece737eb8375803ae11949815a0cb512394d197b9f4ea77115b018092ba3f85c2743d29afa1f3b19876f59494
|
7
|
+
data.tar.gz: 2133f228d5d8cd1846d76b7450d3abd05cfc19a0035aca682adf09dc15cc5972f92f2449f7d9f043db1ec4df42485a8d654e55253d2454bf02d0cbbdbd73900c
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vaibhav Thakkar
|
@@ -46,41 +46,6 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- bin/fictionArt
|
49
|
-
- images/ash_pokemon.jpg
|
50
|
-
- images/batman.jpg
|
51
|
-
- images/baymax.jpg
|
52
|
-
- images/bulbasaur.jpg
|
53
|
-
- images/captain_america.jpg
|
54
|
-
- images/charizard.jpg
|
55
|
-
- images/charmander.jpg
|
56
|
-
- images/doctor_strange.jpg
|
57
|
-
- images/doofenshmirtz.jpg
|
58
|
-
- images/doraemon.jpg
|
59
|
-
- images/ferb.jpg
|
60
|
-
- images/gian.jpg
|
61
|
-
- images/goku.jpg
|
62
|
-
- images/hawkeye.jpg
|
63
|
-
- images/hulk.jpg
|
64
|
-
- images/humungousaur.jpg
|
65
|
-
- images/ironman.jpg
|
66
|
-
- images/joker.jpg
|
67
|
-
- images/krrish.jpg
|
68
|
-
- images/nobita.jpg
|
69
|
-
- images/oggy.jpg
|
70
|
-
- images/perry.jpg
|
71
|
-
- images/phineas.jpg
|
72
|
-
- images/pikachu.jpg
|
73
|
-
- images/shizuka.jpg
|
74
|
-
- images/spiderman.jpg
|
75
|
-
- images/squirtle.jpg
|
76
|
-
- images/suneo.jpg
|
77
|
-
- images/superman.jpg
|
78
|
-
- images/thanos.jpg
|
79
|
-
- images/thor.jpg
|
80
|
-
- images/tom_and_jerry.jpg
|
81
|
-
- images/vegeta.jpg
|
82
|
-
- images/vision.jpg
|
83
|
-
- lib/fictionArt.rb
|
84
49
|
homepage: https://github.com/vaithak/fictionArt
|
85
50
|
licenses:
|
86
51
|
- MIT
|
data/images/ash_pokemon.jpg
DELETED
Binary file
|
data/images/batman.jpg
DELETED
Binary file
|
data/images/baymax.jpg
DELETED
Binary file
|
data/images/bulbasaur.jpg
DELETED
Binary file
|
data/images/captain_america.jpg
DELETED
Binary file
|
data/images/charizard.jpg
DELETED
Binary file
|
data/images/charmander.jpg
DELETED
Binary file
|
data/images/doctor_strange.jpg
DELETED
Binary file
|
data/images/doofenshmirtz.jpg
DELETED
Binary file
|
data/images/doraemon.jpg
DELETED
Binary file
|
data/images/ferb.jpg
DELETED
Binary file
|
data/images/gian.jpg
DELETED
Binary file
|
data/images/goku.jpg
DELETED
Binary file
|
data/images/hawkeye.jpg
DELETED
Binary file
|
data/images/hulk.jpg
DELETED
Binary file
|
data/images/humungousaur.jpg
DELETED
Binary file
|
data/images/ironman.jpg
DELETED
Binary file
|
data/images/joker.jpg
DELETED
Binary file
|
data/images/krrish.jpg
DELETED
Binary file
|
data/images/nobita.jpg
DELETED
Binary file
|
data/images/oggy.jpg
DELETED
Binary file
|
data/images/perry.jpg
DELETED
Binary file
|
data/images/phineas.jpg
DELETED
Binary file
|
data/images/pikachu.jpg
DELETED
Binary file
|
data/images/shizuka.jpg
DELETED
Binary file
|
data/images/spiderman.jpg
DELETED
Binary file
|
data/images/squirtle.jpg
DELETED
Binary file
|
data/images/suneo.jpg
DELETED
Binary file
|
data/images/superman.jpg
DELETED
Binary file
|
data/images/thanos.jpg
DELETED
Binary file
|
data/images/thor.jpg
DELETED
Binary file
|
data/images/tom_and_jerry.jpg
DELETED
Binary file
|
data/images/vegeta.jpg
DELETED
Binary file
|
data/images/vision.jpg
DELETED
Binary file
|
data/lib/fictionArt.rb
DELETED
@@ -1,123 +0,0 @@
|
|
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
|