From dd7a736624d8451600fc2930597b839cb7c3286f Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 4 Jun 2021 13:04:47 -0500 Subject: [PATCH] update gradient for better nushell comparisons --- coloring/gradient_40x160.ps1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 coloring/gradient_40x160.ps1 diff --git a/coloring/gradient_40x160.ps1 b/coloring/gradient_40x160.ps1 new file mode 100644 index 0000000..efcf639 --- /dev/null +++ b/coloring/gradient_40x160.ps1 @@ -0,0 +1,27 @@ +function Set-Cursor { + [CmdletBinding()] + param ([int] $x, [int] $y) + $Host.UI.RawUI.CursorPosition = @{x = $x; y = $y } +} + +function Get-Character { + [CmdletBinding()] + param ([int]$index) + $mystring = ' Trevor Sullivan' + return $index -ge ($mystring.Length) ? ' ' : $mystring[$index] +} + +function main { + # This is the same script as gradient.ps1 but hard coded + # to 40x160 for nushell comparisions + for ($y = 0; $y -le 39; $y++) { + $Color = 25 + Set-Cursor -x $PSItem -y $y + 0..159 | ForEach-Object { + Write-Host -Object ("`e[48;2;0;0;$Color`m{0}" -f (Get-Character -Index $PSItem)) -NoNewline + $Color += 2 + } + } +} + +main