Private/Show-Logo.ps1

#!/usr/bin/env pwsh
# Auto-generated by PX2PS 2025.12.29
# Source: ADCSGoatColorful.px (21x24)
# Generated: 2026-10-06 09:12:15

# Banner labels appear at the goat's upper right in the terminal's default text color.
# Version is read from the module manifest at runtime so the build-time CalVer stamp is always shown.
$manifestPath = Join-Path -Path $PSScriptRoot -ChildPath '..\ADCSGoat.psd1'
$calVer = try {
    (Import-PowerShellDataFile -Path $manifestPath -ErrorAction Stop).ModuleVersion
} catch {
    'unknown'
}
$labelColumn = 15
$rowLabels = @{
    6 = ' ADCSGoat'
    8 = "v$calVer"
}

# Enable Virtual Terminal Processing for ANSI colors (Windows PowerShell 5.1 compatibility)
if ($PSVersionTable.PSVersion.Major -le 5 -and $env:OS -eq 'Windows_NT' -and $Host.Name -ne 'Windows PowerShell ISE Host') {
    try {
        Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class VTConsole {
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern IntPtr GetStdHandle(int nStdHandle);
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
    public static void EnableVT() {
        IntPtr handle = GetStdHandle(-11);
        uint mode;
        GetConsoleMode(handle, out mode);
        SetConsoleMode(handle, mode | 0x4);
    }
}
"@
 -ErrorAction SilentlyContinue
        [VTConsole]::EnableVT()
    } catch {
        # VT processing may already be enabled or not available
    }
}

$ESC = [char]27
$LowerHalfBlock = [char]0x2584
$UpperHalfBlock = [char]0x2580

function ConvertTo-ConsoleColor {
    param([int]$R, [int]$G, [int]$B)
    $colorMap = @(
        @{ Color = [System.ConsoleColor]::Black;       R = 0;   G = 0;   B = 0   }
        @{ Color = [System.ConsoleColor]::DarkBlue;    R = 0;   G = 0;   B = 128 }
        @{ Color = [System.ConsoleColor]::DarkGreen;   R = 0;   G = 128; B = 0   }
        @{ Color = [System.ConsoleColor]::DarkCyan;    R = 0;   G = 128; B = 128 }
        @{ Color = [System.ConsoleColor]::DarkRed;     R = 128; G = 0;   B = 0   }
        @{ Color = [System.ConsoleColor]::DarkMagenta; R = 128; G = 0;   B = 128 }
        @{ Color = [System.ConsoleColor]::DarkYellow;  R = 128; G = 128; B = 0   }
        @{ Color = [System.ConsoleColor]::Gray;        R = 192; G = 192; B = 192 }
        @{ Color = [System.ConsoleColor]::DarkGray;    R = 128; G = 128; B = 128 }
        @{ Color = [System.ConsoleColor]::Blue;        R = 0;   G = 0;   B = 255 }
        @{ Color = [System.ConsoleColor]::Green;       R = 0;   G = 255; B = 0   }
        @{ Color = [System.ConsoleColor]::Cyan;        R = 0;   G = 255; B = 255 }
        @{ Color = [System.ConsoleColor]::Red;         R = 255; G = 0;   B = 0   }
        @{ Color = [System.ConsoleColor]::Magenta;     R = 255; G = 0;   B = 255 }
        @{ Color = [System.ConsoleColor]::Yellow;      R = 255; G = 255; B = 0   }
        @{ Color = [System.ConsoleColor]::White;       R = 255; G = 255; B = 255 }
    )
    $nearestColor = [System.ConsoleColor]::Black
    $minDistance = [int]::MaxValue
    foreach ($entry in $colorMap) {
        $dr = $R - $entry.R
        $dg = $G - $entry.G
        $db = $B - $entry.B
        $distance = ($dr * $dr) + ($dg * $dg) + ($db * $db)
        if ($distance -lt $minDistance) {
            $minDistance = $distance
            $nearestColor = $entry.Color
        }
    }
    return $nearestColor
}

function Get-TrueColorFg {
    param([int]$R, [int]$G, [int]$B)
    return "$ESC[38;2;${R};${G};${B}m"
}

function Get-TrueColorBg {
    param([int]$R, [int]$G, [int]$B)
    return "$ESC[48;2;${R};${G};${B}m"
}

$width = 21
$height = 24
$pixels = @(
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(48,25,52,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(48,25,52,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(248,248,248,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(48,25,52,255),
    @(255,112,112,255),
    @(48,25,52,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(48,25,52,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(248,248,248,255),
    @(248,248,248,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(248,248,248,255),
    @(248,248,248,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(248,248,248,255),
    @(248,248,248,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(248,248,248,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(248,248,248,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(248,248,248,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(248,248,248,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,112,112,255),
    @(214,214,255,255),
    @(255,112,112,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(48,25,52,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(255,255,255,255),
    @(0,0,0,0),
    @(0,0,0,0),
    @(0,0,0,0)
)

$oddHeight = ($height % 2) -eq 1
$startY = if ($oddHeight) { -1 } else { 0 }
$endY = if ($oddHeight) { $height - 1 } else { $height }

Write-Host ''

if ($Host.Name -eq 'Windows PowerShell ISE Host') {
    for ($y = $startY; $y -lt $endY; $y += 2) {
        Write-Host ' ' -NoNewline
        $rowWidth = if ($rowLabels.ContainsKey($y)) { $labelColumn } else { $width }
        for ($x = 0; $x -lt $rowWidth; $x++) {
            $topY = $y
            $bottomY = $y + 1

            if ($topY -lt 0) {
                $topPixel = $null
            } else {
                $topIdx = ($topY * $width) + $x
                $topPixel = if ($topIdx -lt $pixels.Count) { $pixels[$topIdx] } else { @(0, 0, 0, 0) }
            }

            $bottomIdx = ($bottomY * $width) + $x
            $bottomPixel = if ($bottomIdx -lt $pixels.Count) { $pixels[$bottomIdx] } else { @(0, 0, 0, 0) }

            $topTransparent = ($null -eq $topPixel) -or ($topPixel[3] -lt 32)
            $bottomTransparent = $bottomPixel[3] -lt 32

            if (-not $topTransparent -and -not $bottomTransparent) {
                $fgColor = ConvertTo-ConsoleColor -R $bottomPixel[0] -G $bottomPixel[1] -B $bottomPixel[2]
                $bgColor = ConvertTo-ConsoleColor -R $topPixel[0] -G $topPixel[1] -B $topPixel[2]
                Write-Host $LowerHalfBlock -ForegroundColor $fgColor -BackgroundColor $bgColor -NoNewline
            } elseif (-not $topTransparent -and $bottomTransparent) {
                $fgColor = ConvertTo-ConsoleColor -R $topPixel[0] -G $topPixel[1] -B $topPixel[2]
                Write-Host $UpperHalfBlock -ForegroundColor $fgColor -NoNewline
            } elseif ($topTransparent -and -not $bottomTransparent) {
                $fgColor = ConvertTo-ConsoleColor -R $bottomPixel[0] -G $bottomPixel[1] -B $bottomPixel[2]
                Write-Host $LowerHalfBlock -ForegroundColor $fgColor -NoNewline
            } else {
                Write-Host ' ' -NoNewline
            }
        }
        if ($rowLabels.ContainsKey($y)) {
            Write-Host $rowLabels[$y] -NoNewline
        }
        Write-Host ''
    }

    Write-Host ''
} else {
    for ($y = $startY; $y -lt $endY; $y += 2) {
        $line = "$ESC[0m "
        $rowWidth = if ($rowLabels.ContainsKey($y)) { $labelColumn } else { $width }
        for ($x = 0; $x -lt $rowWidth; $x++) {
            $topY = $y
            $bottomY = $y + 1

            if ($topY -lt 0) {
                $topPixel = $null
            } else {
                $topIdx = ($topY * $width) + $x
                $topPixel = if ($topIdx -lt $pixels.Count) { $pixels[$topIdx] } else { @(0, 0, 0, 0) }
            }

            $bottomIdx = ($bottomY * $width) + $x
            $bottomPixel = if ($bottomIdx -lt $pixels.Count) { $pixels[$bottomIdx] } else { @(0, 0, 0, 0) }

            $topTransparent = ($null -eq $topPixel) -or ($topPixel[3] -lt 32)
            $bottomTransparent = $bottomPixel[3] -lt 32

            if (-not $topTransparent -and -not $bottomTransparent) {
                $bg = Get-TrueColorBg -R $topPixel[0] -G $topPixel[1] -B $topPixel[2]
                $fg = Get-TrueColorFg -R $bottomPixel[0] -G $bottomPixel[1] -B $bottomPixel[2]
                $line += "${bg}${fg}$LowerHalfBlock"
            } elseif (-not $topTransparent -and $bottomTransparent) {
                $fg = Get-TrueColorFg -R $topPixel[0] -G $topPixel[1] -B $topPixel[2]
                $line += "$ESC[0m${fg}$UpperHalfBlock"
            } elseif ($topTransparent -and -not $bottomTransparent) {
                $fg = Get-TrueColorFg -R $bottomPixel[0] -G $bottomPixel[1] -B $bottomPixel[2]
                $line += "$ESC[0m${fg}$LowerHalfBlock"
            } else {
                $line += "$ESC[0m "
            }
        }
        if ($rowLabels.ContainsKey($y)) {
            $line += "$ESC[0m$($rowLabels[$y])"
        }
        $line += "$ESC[0m$ESC[K"
        Write-Host $line
    }

    Write-Host ""
}