mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
autoview-type gradient (#146)
This commit is contained in:
parent
cf769798a6
commit
166a9b5eac
2 changed files with 24 additions and 4 deletions
20
engine-q/coloring/gradient-autoview.nu
Normal file
20
engine-q/coloring/gradient-autoview.nu
Normal file
|
@ -0,0 +1,20 @@
|
|||
# this script will print a blue gradient on the screen
|
||||
# it's intended to simulate nushell v0.44 with autoview
|
||||
|
||||
let height = (term size).rows - 3 # calculate height
|
||||
let width = (term size).columns - 5 # calculate width
|
||||
let stamp_start = $width * 1.25 # calculate where to start Nu stamp
|
||||
let stamp_end = $width * 1.3125 # calculate where to stop Nu stamp
|
||||
let stamp = 'Nu'
|
||||
seq 0 $height | par-each { # create these in parallel
|
||||
let row_data = (seq 0 $width | each { |col|
|
||||
let fgcolor = 2 + 2 * $col
|
||||
if $fgcolor > $stamp_start && $fgcolor < $stamp_end {
|
||||
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
|
||||
} else {
|
||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||
}
|
||||
} | str collect)
|
||||
$"($row_data)" | table
|
||||
$nothing
|
||||
} | compact
|
|
@ -1,9 +1,5 @@
|
|||
# this script will print a blue gradient on the screen
|
||||
|
||||
def iter_inc [incr mult iter] {
|
||||
$incr + $mult * $iter
|
||||
}
|
||||
|
||||
# We can get the terminal width and height now with term size
|
||||
# but we like to use the script as a benchmark, so let's keep
|
||||
# it a constant size for now
|
||||
|
@ -22,6 +18,10 @@ seq 0 $height | each {
|
|||
$"($row_data)(char newline)"
|
||||
} | str collect
|
||||
|
||||
def iter_inc [incr mult iter] {
|
||||
$incr + $mult * $iter
|
||||
}
|
||||
|
||||
|
||||
# ╭────────────────────┬──────────────────────────────────────────────────────╮
|
||||
# │ version │ 0.1.0 │
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue