ombre 0.0.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 +7 -0
- data/lib/ombre.rb +41 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bbf20e9c3c9c4424d3ae4f3675ec90e2532b07d5f127b2dd52ca03dfad89fd82
|
4
|
+
data.tar.gz: 8ec60035f8581e0b5b3b9e70029730db208732b536b0d132f58d0974cada9b6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56050a7bec0ec9a6af03c8fda56a53220cc630b79a0b31a4a88082e5a74ad920841a754f6c0308b6fe418ed0b122b85b812dd2bce8ec75d5fd3085bf54c16848
|
7
|
+
data.tar.gz: e7fac2bd9ca52d54ead214917ffedd620b92a1f50ae582ca328e9a0344cc3ed77f1f5ff60ad01c4842e71277ac3590fa88007f25aa426fc92ad68c2cb0c98429
|
data/lib/ombre.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
class Ombre
|
2
|
+
def self.vertical color1, color2, text
|
3
|
+
red1, green1, blue1 = get_colors(color1)
|
4
|
+
red2, green2, blue2 = get_colors(color2)
|
5
|
+
r_step, g_step, b_step = get_steps(color1, color2, text.lines.count)
|
6
|
+
text.lines.each_with_index.map do |line, i|
|
7
|
+
color_text (red1 + i * r_step), (green1 + i * g_step), (blue1 + i * b_step), line
|
8
|
+
end.join
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.horizontal color1, color2, text
|
12
|
+
red1, green1, blue1 = get_colors(color1)
|
13
|
+
red2, green2, blue2 = get_colors(color2)
|
14
|
+
r_step, g_step, b_step = get_steps(color1, color2, text.lines.max.length)
|
15
|
+
text.lines.map do |line|
|
16
|
+
line.chars.each_with_index.map do |line, i|
|
17
|
+
color_text (red1 + i * r_step), (green1 + i * g_step), (blue1 + i * b_step), line
|
18
|
+
end.join
|
19
|
+
end.join
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.get_colors color
|
25
|
+
color = color.gsub('#','')
|
26
|
+
red = color[0..1].to_i(16).to_f
|
27
|
+
green = color[2..3].to_i(16).to_f
|
28
|
+
blue = color[4..5].to_i(16).to_f
|
29
|
+
[red, green, blue]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.get_steps c1, c2, i
|
33
|
+
r1, g1, b1 = get_colors c1
|
34
|
+
r2, g2, b2 = get_colors c2
|
35
|
+
[(r2-r1)/i.to_f, (g2-g1)/i.to_f, (b2-b1)/i.to_f]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.color_text r, g, b, text
|
39
|
+
"\x1b[38;2;#{r.to_i};#{g.to_i};#{b.to_i}m#{text}"
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ombre
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Paulson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides gradient colors for the command line using truecolor
|
14
|
+
email: jpaulson@hey.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ombre.rb
|
20
|
+
homepage: https://rubygems.org/gems/ombre
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.1.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Ombre
|
43
|
+
test_files: []
|