File: colorize_spesh.p6

package info (click to toggle)
moarvm 2020.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,652 kB
  • sloc: ansic: 268,178; perl: 8,186; python: 1,316; makefile: 768; sh: 287
file content (12 lines) | stat: -rwxr-xr-x 405 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env perl6

sub colorblock($num, $ver) {
    "\e[48;5;{ 0x10 + (($num + 1) * 31416) % 216 }m  "
    ~ "\e[38;5;{ 0xE8 + 24 - ($num + $ver * 5) % 24 }m\c[ BLACK LEFT-POINTING TRIANGLE ]"
    ~ "\e[48;5;0m\c[ BLACK RIGHT-POINTING TRIANGLE ]"
    ~ "\e[m"
}

for lines() :eager -> $_ is copy {
    .subst( /r(<.digit>+) '(' (<.digit>+) ')' /, -> $/ { "r$0\($1\)" ~ colorblock($0, $1) }, :g ).say
}