1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Merge pull request #42 from fdncred/24bit_test

24bit testing
This commit is contained in:
Darren Schroeder 2021-04-12 08:57:18 -05:00 committed by GitHub
commit 7de79470c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

39
coloring/24bit-1.nu Normal file
View file

@ -0,0 +1,39 @@
let term_cols = $(= $(term size -w) - 1)
echo 0..$term_cols |
each {
let r = $(= 255 - ($it * 255 / $term_cols) | math round)
let g = $(= $it * 510 / $term_cols | math round)
let b = $(= $it * 255 / $term_cols | math round)
if $g > 255 {
let g = $(= 510 - $g)
echo $(build-colorstr $r $g $b) | autoview
} {
echo $(build-colorstr $r $g $b) | autoview
}
}
def build-colorstr [
r:int # Red
g:int # Green
b:int # Blue
] {
# log $(build-string "R=" $r " G=" $g " B=" $b)
let bg = $(build-string $(ansi rgb_bg) $r ';' $g ';' $b 'm')
let fg = $(build-string $(ansi rgb_fg) $(= 255 - $r) ';' $(= 255 - $g) ';' $(= 255 - $b) 'm')
let idx = $(= $it mod 2)
let slash_str = $(if $idx == 0 {
build-string "/" $(ansi reset)
} {
build-string "\" $(ansi reset)
})
build-string $bg $fg $slash_str
# log $(build-string $bg $fg $slash_str | debug)
}
# This is a first attempt and some type of logging
def log [message:any] {
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
let mess = $(build-string $now '|DBG|' $message $(char newline))
echo $mess | autoview
}