GetFunky_ASCII_ART_Colors.bat
:salut:
Je sais que cette discussion est :resolu: mais juste je veux partager quelque chose pour savoir comment coloriser cet ASCII ART avec un code hybrid Batch et Powershell :
Donc vous avez juste à modifier avec un copier et coller votre ASCII ART entre cette variable en powershell :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| $text = @"
___ __ _ _
|_ _| _ __ / _| ___ _ __ _ __ ___ __ _ | |_ (_) ___ _ __
| | | '_ \ | |_ / _ \ | '__|| '_ ` _ \ / _` || __|| | / _ \ | '_ \
| | | | | || _|| (_) || | | | | | | || (_| || |_ | || (_) || | | |
|___||_| |_||_| \___/ |_| |_| |_| |_| \__,_| \__||_| \___/ |_| |_|
"@ |
Le code Batch en question est : GetFunky_ASCII_ART_Colors.bat
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <# : batch script Don't Delete This Line.
@rem # The previous line does nothing in Batch, but begins a multiline comment block in PowerShell. This allows a single script to be executed by both interpreters.
@echo off
Title Get Funky ASCII ART with Colors
setlocal
cd "%~dp0"
Color 0B & echo(
Echo( This ASCII ART is interpreted with powershell command
Powershell -executionpolicy remotesigned -Command "Invoke-Expression $([System.IO.File]::ReadAllText('%~f0'))"
EndLocal
pause
@rem # Here you can put other Commands in batch
cls & Echo( Those are another commands with Batch like ping and ipconfig /all and so on ....
Timeout /T 1 /NoBreak>nul
Ping www.google.com
echo( & Ipconfig /all & pause
goto:eof
#>
# here write your powershell commands...
# https://stackoverflow.com/a/35022366/3080770
function Get-Funky{
param([string]$Text)
# Use a random colour for each character
$Text.ToCharArray() | ForEach-Object{
switch -Regex ($_){
# Ignore new line characters
"`r"{
break
}
# Start a new line
"`n"{
Write-Host " ";break
}
# Use random colours for displaying this non-space character
"[^ ]"{
# Splat the colours to write-host
$writeHostOptions = @{
ForegroundColor = ([system.enum]::GetValues([system.consolecolor])) | get-random
# BackgroundColor = ([system.enum]::GetValues([system.consolecolor])) | get-random
NoNewLine = $true
}
Write-Host $_ @writeHostOptions
break
}
" "{Write-Host " " -NoNewline}
}
}
}
$text = @"
___ __ _ _
|_ _| _ __ / _| ___ _ __ _ __ ___ __ _ | |_ (_) ___ _ __
| | | '_ \ | |_ / _ \ | '__|| '_ ` _ \ / _` || __|| | / _ \ | '_ \
| | | | | || _|| (_) || | | | | | | || (_| || |_ | || (_) || | | |
|___||_| |_||_| \___/ |_| |_| |_| |_| \__,_| \__||_| \___/ |_| |_|
"@
$text # You can delete or comment this line in order to show only the colorized ASCII ART
Get-Funky $text |