PoshCode Archive  Artifact [f8fab31b84]

Artifact f8fab31b84ddd4003f1347b2e4d6ba226264bf906d076e2b0b9e3b4d29da1a68:

  • File Draw.ps1 — part of check-in [e91b9cf5cf] at 2018-06-10 14:14:39 on branch trunk — Turns a here-string with characters, spaces, and new lines into an image with blocks of color, spaces, and new lines. (user: Nathan Estell size: 779)

# encoding: ascii
# api: powershell
# title: Draw
# description: Turns a here-string with characters, spaces, and new lines into an image with blocks of color, spaces, and new lines.
# version: 0.1
# type: function
# author: Nathan Estell
# license: CC0
# x-poshcode-id: 6383
# x-archived: 2016-06-17T09:15:30
# x-published: 2016-06-14T18:08:00
#
#
function Draw
{
param
(
$text=@"
q   
 q  
  q 
   q
"@
)
$CharArray=$text.tochararray()
foreach ($character in $CharArray)
{
if ($character -match "\S" )
{
write-host " " -BackgroundColor "Green" -NoNewLine
#"Character"
}
if ($character -match "[^\S\r\n]")
{
write-host " " -BackgroundColor "Black" -NoNewLine
#"Space"
}
if ($character -match "\n" )
{
write-host "" 
#"New Line"
}
}
}