79 lines
3.5 KiB
PowerShell
79 lines
3.5 KiB
PowerShell
#region Get-ColorPalette
|
|
Function Get-ColorPalette
|
|
{
|
|
<#
|
|
.SYNOPSIS
|
|
Returns a named palette of hexadecimal colors used to give VLANs and wireless networks a consistent visual identity.
|
|
|
|
.DESCRIPTION
|
|
Rackpad accepts a color against a VLAN and against an SSID, and uses it to tint every place that object appears. Leaving the
|
|
color empty produces a uniform and largely unreadable view, so a palette is applied automatically.
|
|
|
|
The palette is returned as an ordered dictionary of name to hexadecimal value. Names are carried rather than discarded because
|
|
they make a log message legible, and because the caller can select a specific color by name when something deserves a fixed
|
|
identity.
|
|
|
|
Colors are deliberately spaced around the wheel rather than listed in spectral order, so that two objects allocated one after
|
|
another are easy to tell apart. Every entry is a mid tone that remains legible against both a light and a dark background.
|
|
|
|
.PARAMETER Name
|
|
The palette to return.
|
|
|
|
.EXAMPLE
|
|
$ColorPalette = Get-ColorPalette
|
|
|
|
$ColorQueue = New-Object -TypeName 'System.Collections.Generic.Queue[System.String]'
|
|
|
|
ForEach ($ColorEntry In $ColorPalette.GetEnumerator()) {$ColorQueue.Enqueue($ColorEntry.Value)}
|
|
|
|
.NOTES
|
|
Author: Grace Solutions
|
|
Version: 2026.08.02.0000
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
Param
|
|
(
|
|
[Parameter(Mandatory=$False)]
|
|
[ValidateSet('Default')]
|
|
[String]$Name = 'Default'
|
|
)
|
|
|
|
Try
|
|
{
|
|
$ColorPalette = New-Object -TypeName 'System.Collections.Generic.Dictionary[[System.String], [System.String]]'
|
|
|
|
Switch ("$($Name)")
|
|
{
|
|
Default
|
|
{
|
|
$Null = $ColorPalette.Add('Blue', '#3B82F6')
|
|
$Null = $ColorPalette.Add('Amber', '#F59E0B')
|
|
$Null = $ColorPalette.Add('Emerald', '#10B981')
|
|
$Null = $ColorPalette.Add('Violet', '#8B5CF6')
|
|
$Null = $ColorPalette.Add('Rose', '#F43F5E')
|
|
$Null = $ColorPalette.Add('Cyan', '#06B6D4')
|
|
$Null = $ColorPalette.Add('Orange', '#F97316')
|
|
$Null = $ColorPalette.Add('Lime', '#84CC16')
|
|
$Null = $ColorPalette.Add('Indigo', '#6366F1')
|
|
$Null = $ColorPalette.Add('Pink', '#EC4899')
|
|
$Null = $ColorPalette.Add('Teal', '#14B8A6')
|
|
$Null = $ColorPalette.Add('Yellow', '#EAB308')
|
|
$Null = $ColorPalette.Add('Purple', '#A855F7')
|
|
$Null = $ColorPalette.Add('Sky', '#0EA5E9')
|
|
$Null = $ColorPalette.Add('Red', '#EF4444')
|
|
$Null = $ColorPalette.Add('Green', '#22C55E')
|
|
$Null = $ColorPalette.Add('Fuchsia', '#D946EF')
|
|
$Null = $ColorPalette.Add('Slate', '#64748B')
|
|
}
|
|
}
|
|
|
|
Write-Output -InputObject ($ColorPalette)
|
|
}
|
|
Catch
|
|
{
|
|
Throw
|
|
}
|
|
}
|
|
#endregion
|