rothko 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rothko/version.rb +1 -1
- data/lib/rothko.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a35f7607e9e6bd3ab8455839fb9f87376c4c52c4517dd5fa737da94d1e95730
|
4
|
+
data.tar.gz: 75e453b1228ff7c15b5a9beee6c20bdb5e3bdaf9cb1146c66f13c3145c6d56b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a0e4ea14924d6696206314923bcac877cc2bbb0ccc648b6ce4a2b17b9924cc885c63411cb123df768a5b553f61813f24b8385a74b7c8710bad61ffc8eaaf48
|
7
|
+
data.tar.gz: 7125e146a4d68315ca04ac1ff6ebe8b711071be045b8001864aab7cfb8463006254ae8b23fc28c63b5ddebf38d5481b9f536d39ec20dad2cf69a804fbcbe067d
|
data/lib/rothko/version.rb
CHANGED
data/lib/rothko.rb
CHANGED
@@ -7,13 +7,13 @@ module Rothko
|
|
7
7
|
class Drawing
|
8
8
|
|
9
9
|
attr_accessor :img, :width
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :palette
|
11
11
|
|
12
12
|
include ChunkyPNG::Color
|
13
13
|
|
14
14
|
# Pallette of default ANSI colors. Closest match is found from this hash,
|
15
15
|
# so these may be altered to produce a more faithful image or change colors.
|
16
|
-
@@
|
16
|
+
@@palette = {
|
17
17
|
"g" => [0,230,22],
|
18
18
|
"G" => [0,176,14],
|
19
19
|
"w" => [230,229,230],
|
@@ -50,7 +50,7 @@ module Rothko
|
|
50
50
|
|
51
51
|
# Finds height of the image relative to provided width
|
52
52
|
def get_height(img)
|
53
|
-
new_height = img.height / (img.width / self.width)
|
53
|
+
new_height = img.height / (img.width.to_f / self.width.to_f)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Iterates over each pixel of resized image to find closest color
|
@@ -64,11 +64,11 @@ module Rothko
|
|
64
64
|
end.join
|
65
65
|
end
|
66
66
|
|
67
|
-
# Iterates over the
|
67
|
+
# Iterates over the palette to find the most similar color
|
68
68
|
def find_closest_term_color(pixel_values)
|
69
69
|
color = ""
|
70
70
|
lil_dist = 195075
|
71
|
-
@@
|
71
|
+
@@palette.each do |col_name, col_values|
|
72
72
|
dist = find_distance(col_values, pixel_values)
|
73
73
|
if dist < lil_dist
|
74
74
|
lil_dist = dist
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rothko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Brennan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides the 'Drawing' class which is initialized with a filepath and
|
14
14
|
a width. The image will be processed and put to the terminal as a collection of
|