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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c35cadf13e2e698a28b12ea3ebd38b58bf42b4a9a2e9e212ac4250599bb46581
4
- data.tar.gz: f244c22ead51765dcf5b6ff2258db9d8459aea740f94b6d2c5e553247daf7015
3
+ metadata.gz: 3cee34142b88b8607296f7118a43b29379f8355bf175642c61f6641d5a21603e
4
+ data.tar.gz: e764306950aa1514f17d198fa5bd3fe15e11f227098cdc1905c2fa15ca9752bd
5
5
  SHA512:
6
- metadata.gz: 88ac1247e6e7784e31231d6fb0887714203ac2bf64118783273e1f3d7ce071ad68c14f827f40d9614d12e3f51375b505b7e959c2f08e79387a0f524ec5778e64
7
- data.tar.gz: 2a3a125c26f8c6c27029d4eb366ea8ddd5a518646ddfe587810c9cf250f07398f6ff41ba511ac9ef66d04d9f0543188684848e8ab74bebd189baa7d8fc791578
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.1
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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -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