artsy 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/artsy.rb +65 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a175378932a34cc922a87e42896ebe230c9d536d4201245097a681c617930927
|
4
|
+
data.tar.gz: 2594faadfd97a6fda4e158ae811f9667888270b6597ffc08e742ba87be9ce3c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '089e0fc334a0ed0c959845f461e0d2e0e1776d8d2db8ab78230f155319310b4ae5b29dd5a9a859ffbd3b51a94ce21dd1862d5963a2ce86fd281e46c30375fd38'
|
7
|
+
data.tar.gz: f0f777e5d23aa55fd39343e7833bba4a41c23233e36d2af6fed17214762696a2a5dd24cf294c10cd4acaec6dd9aefde663fe6c42e289437f0da1d6871b0559eb
|
data/lib/artsy.rb
CHANGED
@@ -44,6 +44,71 @@ class Artsy
|
|
44
44
|
puts "#{printcolor}#{text}#{definedColours[0]}" # done!
|
45
45
|
elsif formatting == "bold"
|
46
46
|
puts "#{printcolor}\033[1m#{text}#{definedColours[0]}"
|
47
|
+
elsif formatting == "underline"
|
48
|
+
puts "#{printcolor}\033[4m#{text}#{definedColours[0]}"
|
49
|
+
elsif formatting == "italics"
|
50
|
+
# WARNING: Not widely supported by terminal emulators.
|
51
|
+
puts "#{printcolor}\033[3m#{text}#{definedColours[0]}"
|
47
52
|
end
|
48
53
|
end
|
54
|
+
def self.gradientOut(text, r1, g1, b1, r2, g2, b2, stepping, debug = 0)
|
55
|
+
# prints text with a gradient
|
56
|
+
# increases every value by stepping per character
|
57
|
+
arr_Text = text.split("") # split text into array of characters
|
58
|
+
if debug == 1
|
59
|
+
# show array
|
60
|
+
puts arr_Text
|
61
|
+
end
|
62
|
+
count = arr_Text.count
|
63
|
+
if debug == 1
|
64
|
+
puts count
|
65
|
+
end
|
66
|
+
count_cap = count - 1
|
67
|
+
cr = r1
|
68
|
+
cg = g1
|
69
|
+
cb = b1
|
70
|
+
for i in 0..count_cap
|
71
|
+
# iterate over characters
|
72
|
+
if r1 < r2
|
73
|
+
# if less than r2, +step and check nr accordingly
|
74
|
+
nr = cr + stepping
|
75
|
+
if nr < r2
|
76
|
+
# as long as less than r2, increment by stepping
|
77
|
+
cr = nr # cr is now nr
|
78
|
+
end
|
79
|
+
else
|
80
|
+
# -step and check nr differently
|
81
|
+
nr = cr - stepping
|
82
|
+
if nr > r2
|
83
|
+
cr = nr
|
84
|
+
end
|
85
|
+
end
|
86
|
+
if g1 < g2
|
87
|
+
ng = cg + stepping
|
88
|
+
if ng < g2
|
89
|
+
# green
|
90
|
+
cg = ng
|
91
|
+
end
|
92
|
+
else
|
93
|
+
ng = cg - stepping
|
94
|
+
if ng > g2
|
95
|
+
cg = ng
|
96
|
+
end
|
97
|
+
end
|
98
|
+
if b1 < b2
|
99
|
+
nb = cb + stepping
|
100
|
+
if nb < b2
|
101
|
+
cb = nb
|
102
|
+
end
|
103
|
+
else
|
104
|
+
nb = cb - stepping
|
105
|
+
if nb > b2
|
106
|
+
cb = nb
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# in conclusion, don't increase if next color exceeds endpoint
|
110
|
+
print "\033[38;2;#{cr};#{cg};#{cb}m#{arr_Text[i]}\033[0m"
|
111
|
+
end
|
112
|
+
print "\n" # print a newline
|
113
|
+
end
|
49
114
|
end
|