forked from nushell/nu_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradient.nu
37 lines (29 loc) · 894 Bytes
/
gradient.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# height = 40
# width = 160
# stamp = "py"
# for line in range(0, height):
# row_data = ""
# for col in range(0, width):
# fgcolor = 2 + 2 * col
# if fgcolor > 200 and fgcolor < 210:
# row_data = row_data + color(stamp, bg='rgb(0, 0, %d)' % fgcolor)
# else:
# fg = fgcolor % 256
# row_data = row_data + color(' ', bg='rgb(0, 0, %d)' % fg)
# print(row_data)
const height = 40
const width = 160
const stamp = "Nu"
for line in 0..$height {
mut row_data = ""
for col in 0..$width {
let fgcolor = 2 + 2 * $col
if $fgcolor > 200 and $fgcolor < 210 {
$row_data += $"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
} else {
let fg = $fgcolor mod 256
$row_data += $"(ansi -e '48;2;0;0;')($fg)m (ansi -e '0m')"
}
}
print $row_data
}