branding 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Rakefile +3 -3
- data/lib/branding.rb +0 -1
- data/lib/branding/ansi.rb +12 -12
- data/lib/branding/canvas.rb +9 -13
- data/lib/branding/cli.rb +1 -1
- data/lib/branding/pixel.rb +2 -2
- data/lib/branding/png.rb +6 -4
- data/lib/branding/railtie.rb +0 -1
- data/lib/branding/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6959beaee1359735390dd016cef33521c93f2df
|
4
|
+
data.tar.gz: f7c79a011689a917d6c3ff3917e829721027c512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baed7ed5ef481ad18fe6e13251682af9521286d0f34f64f0486ba91cd2a511eebe3501ce8a1916bd62d5025a412bf2f8f72ecc16723fb14987f03e230644ce81
|
7
|
+
data.tar.gz: aad0af2f3acbb30007ca9ab37542e35d2dbeb55f9d76430bfc9680a48b902af6cd44c14f5a6b2a978a48aa67382574e06cde2f79babadc0c33c99548f4eda140
|
data/.rubocop.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.0
|
data/Rakefile
CHANGED
data/lib/branding.rb
CHANGED
data/lib/branding/ansi.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Branding
|
2
2
|
module ANSI
|
3
|
-
ATTRS = (0..8).map{|i| "\e[#{i}m".to_sym }.freeze
|
4
|
-
FGCOLORS = (0..256).map{|i| "\e[38;5;#{i}m".to_sym }.freeze
|
5
|
-
BGCOLORS = (0..256).map{|i| "\e[48;5;#{i}m".to_sym }.freeze
|
6
|
-
#2580 - 259F
|
3
|
+
ATTRS = (0..8).map { |i| "\e[#{i}m".to_sym }.freeze
|
4
|
+
FGCOLORS = (0..256).map { |i| "\e[38;5;#{i}m".to_sym }.freeze
|
5
|
+
BGCOLORS = (0..256).map { |i| "\e[48;5;#{i}m".to_sym }.freeze
|
6
|
+
# 2580 - 259F
|
7
7
|
SHADERS = [:"\u2591", :"\u2592", :"\u2593"].freeze
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def fg(r,g,b)
|
12
|
-
FGCOLORS[rgb_offset(r,g,b)]
|
11
|
+
def fg(r, g, b)
|
12
|
+
FGCOLORS[rgb_offset(r, g, b)]
|
13
13
|
end
|
14
14
|
|
15
|
-
def bg(r,g,b)
|
16
|
-
BGCOLORS[rgb_offset(r,g,b)]
|
15
|
+
def bg(r, g, b)
|
16
|
+
BGCOLORS[rgb_offset(r, g, b)]
|
17
17
|
end
|
18
18
|
|
19
19
|
def reset
|
@@ -44,7 +44,7 @@ module Branding
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# 0x10-0xE7: 6 × 6 × 6 = 216 colors
|
47
|
-
def rgb_offset(r,g,b)
|
47
|
+
def rgb_offset(r, g, b)
|
48
48
|
16 + (36 * scale_color(r)) + (6 * scale_color(g)) + scale_color(b)
|
49
49
|
end
|
50
50
|
|
@@ -57,18 +57,18 @@ module Branding
|
|
57
57
|
|
58
58
|
# we probably shouldn't be passing in non-ints
|
59
59
|
def uint32_to_rgb(uint32)
|
60
|
-
return [0,0,0] unless uint32.is_a?(Integer)
|
60
|
+
return [0, 0, 0] unless uint32.is_a?(Integer)
|
61
61
|
|
62
62
|
r = (uint32 & 0xff000000) >> 24
|
63
63
|
g = (uint32 & 0x00ff0000) >> 16
|
64
64
|
b = (uint32 & 0x0000ff00) >> 8
|
65
65
|
|
66
|
-
[r,g,b]
|
66
|
+
[r, g, b]
|
67
67
|
end
|
68
68
|
|
69
69
|
# we probably shouldn't be passing in non-ints
|
70
70
|
def clamped(uint32)
|
71
|
-
return [0,0,0] unless uint32.is_a?(Integer)
|
71
|
+
return [0, 0, 0] unless uint32.is_a?(Integer)
|
72
72
|
|
73
73
|
r = (uint32 & 0xff000000) >> 24
|
74
74
|
g = (uint32 & 0x00ff0000) >> 16
|
data/lib/branding/canvas.rb
CHANGED
@@ -6,15 +6,15 @@ module Branding
|
|
6
6
|
|
7
7
|
def self.terminal_size
|
8
8
|
# TODO: make sure we can get this on linux
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
9
|
+
|
10
|
+
`stty size`.split.map(&:to_i)
|
11
|
+
rescue
|
12
|
+
[40, 100]
|
14
13
|
end
|
15
14
|
|
16
|
-
def initialize(width
|
17
|
-
@width
|
15
|
+
def initialize(width: 0, height: 0)
|
16
|
+
@width = width
|
17
|
+
@height = height
|
18
18
|
@rows, @cols = self.class.terminal_size
|
19
19
|
@pixel_buffer = []
|
20
20
|
end
|
@@ -38,13 +38,9 @@ module Branding
|
|
38
38
|
|
39
39
|
def print
|
40
40
|
@pixel_buffer.each_with_index do |pixel, idx|
|
41
|
-
if (idx % width * pixel.width) >= cols
|
42
|
-
next
|
43
|
-
end
|
41
|
+
next if (idx % width * pixel.width) >= cols
|
44
42
|
|
45
|
-
if idx % max_width == 0
|
46
|
-
STDOUT.puts(ANSI.reset)
|
47
|
-
end
|
43
|
+
STDOUT.puts(ANSI.reset) if idx % max_width == 0
|
48
44
|
|
49
45
|
STDOUT.print(pixel)
|
50
46
|
end
|
data/lib/branding/cli.rb
CHANGED
data/lib/branding/pixel.rb
CHANGED
@@ -6,7 +6,7 @@ module Branding
|
|
6
6
|
#
|
7
7
|
#
|
8
8
|
class Pixel
|
9
|
-
def self.load_strategy(pixels, height
|
9
|
+
def self.load_strategy(pixels, height: 0, width: 0)
|
10
10
|
pixels.each do |pixel_value|
|
11
11
|
yield self.new(pixel_value)
|
12
12
|
end
|
@@ -99,7 +99,7 @@ module Branding
|
|
99
99
|
|
100
100
|
class Pixel2x < Pixel
|
101
101
|
|
102
|
-
def self.load_strategy(pixels, height
|
102
|
+
def self.load_strategy(pixels, height: 0, width: 0)
|
103
103
|
matrix = Matrix.build(height, width) do |row, col|
|
104
104
|
pixels[col + row*width]
|
105
105
|
end
|
data/lib/branding/png.rb
CHANGED
@@ -14,7 +14,7 @@ module Branding
|
|
14
14
|
class Imagedata
|
15
15
|
include Enumerable
|
16
16
|
|
17
|
-
def initialize(data
|
17
|
+
def initialize(data: nil, scanline_width: 0, color_channels: 3)
|
18
18
|
@scanline_width = scanline_width
|
19
19
|
@color_channels = color_channels
|
20
20
|
|
@@ -33,7 +33,9 @@ module Branding
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def each_scanline
|
36
|
-
|
36
|
+
# the number of bytes is + 1 because of the filter byte
|
37
|
+
bytes_in_scanline = @scanline_width * @color_channels + 1
|
38
|
+
|
37
39
|
previous_scanline = nil
|
38
40
|
|
39
41
|
each_slice(bytes_in_scanline) do |scanline|
|
@@ -133,10 +135,10 @@ module Branding
|
|
133
135
|
|
134
136
|
# https://www.w3.org/TR/PNG/#9Filter-type-4-Paeth
|
135
137
|
def paeth(x)
|
136
|
-
x + paeth_predictor(a,b,c)
|
138
|
+
x + paeth_predictor(a, b, c)
|
137
139
|
end
|
138
140
|
|
139
|
-
def paeth_predictor(a,b,c)
|
141
|
+
def paeth_predictor(a, b, c)
|
140
142
|
p = a + b - c
|
141
143
|
pa = (p - a).abs
|
142
144
|
pb = (p - b).abs
|
data/lib/branding/railtie.rb
CHANGED
data/lib/branding/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: branding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Natchev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.4
|
135
|
+
rubygems_version: 2.6.4
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Print your logo to the terminal.
|