|
| 1 | +# Okabe-Ito palette: peer-reviewed, safe across all common colorblindness types. |
| 2 | +# Source: https://jfly.uni-koeln.de/color/ |
| 3 | +$script:OKABE_ITO = @{ |
| 4 | + Black = @{ R = 0; G = 0; B = 0 } |
| 5 | + Orange = @{ R = 230; G = 159; B = 0 } |
| 6 | + SkyBlue = @{ R = 86; G = 180; B = 233 } |
| 7 | + BluishGreen = @{ R = 0; G = 158; B = 115 } |
| 8 | + Yellow = @{ R = 240; G = 228; B = 66 } |
| 9 | + Blue = @{ R = 0; G = 114; B = 178 } |
| 10 | + Vermillion = @{ R = 213; G = 94; B = 0 } |
| 11 | + ReddishPurple = @{ R = 204; G = 121; B = 167 } |
| 12 | +} |
| 13 | + |
| 14 | +function Get-ColorBlindPaletteData { |
| 15 | + <# |
| 16 | + .SYNOPSIS |
| 17 | + Returns the RGB color table for a named color blind profile. |
| 18 | +
|
| 19 | + .DESCRIPTION |
| 20 | + Returns a hashtable of named color entries (each with R, G, B keys) for the specified |
| 21 | + color blindness profile. All profiles are derived from the Okabe-Ito palette, adjusted |
| 22 | + per the specific perceptual needs of each condition. |
| 23 | +
|
| 24 | + .PARAMETER ProfileType |
| 25 | + The color blindness profile to retrieve. Valid values: Deuteranopia, Protanopia, |
| 26 | + Tritanopia, Achromatopsia, AccessibleDefault. |
| 27 | +
|
| 28 | + .EXAMPLE |
| 29 | + Get-ColorBlindPaletteData -ProfileType Deuteranopia |
| 30 | + #> |
| 31 | + param ( |
| 32 | + [Parameter(Mandatory = $true)] |
| 33 | + [ValidateSet('Deuteranopia', 'Protanopia', 'Tritanopia', 'Achromatopsia', 'AccessibleDefault')] |
| 34 | + [string]$ProfileType |
| 35 | + ) |
| 36 | + |
| 37 | + switch ($ProfileType) { |
| 38 | + 'Deuteranopia' { |
| 39 | + # Red-green deficiency (most common). Maximize blue/orange/yellow contrast. |
| 40 | + # Red and green are shifted to orange and blue respectively. |
| 41 | + @{ |
| 42 | + Error = $script:OKABE_ITO.Vermillion # Vermillion (not red) |
| 43 | + Warning = $script:OKABE_ITO.Orange # Orange |
| 44 | + Success = $script:OKABE_ITO.Blue # Blue (not green) |
| 45 | + Info = $script:OKABE_ITO.SkyBlue # Sky Blue |
| 46 | + Highlight = $script:OKABE_ITO.Yellow # Yellow |
| 47 | + Accent = $script:OKABE_ITO.ReddishPurple # Reddish Purple |
| 48 | + Text = $script:OKABE_ITO.Black # Black |
| 49 | + Muted = @{ R = 120; G = 120; B = 120 } # Mid-gray (not part of Okabe-Ito) |
| 50 | + } |
| 51 | + } |
| 52 | + 'Protanopia' { |
| 53 | + # Red-weak (cannot perceive red). Red-range hues shifted further toward orange/yellow. |
| 54 | + @{ |
| 55 | + Error = @{ R = 230; G = 159; B = 0 } # Orange (red is invisible) |
| 56 | + Warning = @{ R = 240; G = 228; B = 66 } # Yellow |
| 57 | + Success = @{ R = 0; G = 114; B = 178 } # Blue |
| 58 | + Info = @{ R = 86; G = 180; B = 233 } # Sky Blue |
| 59 | + Highlight = @{ R = 204; G = 121; B = 167 } # Reddish Purple |
| 60 | + Accent = @{ R = 0; G = 158; B = 115 } # Bluish Green |
| 61 | + Text = @{ R = 0; G = 0; B = 0 } # Black |
| 62 | + Muted = @{ R = 120; G = 120; B = 120 } # Mid-gray |
| 63 | + } |
| 64 | + } |
| 65 | + 'Tritanopia' { |
| 66 | + # Blue-yellow deficiency. Shift to red/green contrast; replace blue with high-contrast cyan. |
| 67 | + @{ |
| 68 | + Error = @{ R = 213; G = 94; B = 0 } # Vermillion |
| 69 | + Warning = @{ R = 204; G = 121; B = 167 } # Reddish Purple (not yellow) |
| 70 | + Success = @{ R = 0; G = 158; B = 115 } # Bluish Green |
| 71 | + Info = @{ R = 0; G = 200; B = 200 } # Cyan (high contrast, not pure blue) |
| 72 | + Highlight = @{ R = 255; G = 100; B = 100 } # Light Red (visible to tritanopes) |
| 73 | + Accent = @{ R = 180; G = 60; B = 60 } # Dark Red |
| 74 | + Text = @{ R = 0; G = 0; B = 0 } # Black |
| 75 | + Muted = @{ R = 120; G = 120; B = 120 } # Mid-gray |
| 76 | + } |
| 77 | + } |
| 78 | + 'Achromatopsia' { |
| 79 | + # Full colorblindness. High-contrast grayscale ladder designed for strong separation between steps. |
| 80 | + @{ |
| 81 | + Error = @{ R = 30; G = 30; B = 30 } # Near-black (on white bg) |
| 82 | + Warning = @{ R = 80; G = 80; B = 80 } # Dark gray |
| 83 | + Success = @{ R = 50; G = 50; B = 50 } # Dark gray variant |
| 84 | + Info = @{ R = 110; G = 110; B = 110 } # Medium gray |
| 85 | + Highlight = @{ R = 230; G = 230; B = 230 } # Near-white |
| 86 | + Accent = @{ R = 0; G = 0; B = 0 } # Black |
| 87 | + Text = @{ R = 0; G = 0; B = 0 } # Black |
| 88 | + Muted = @{ R = 160; G = 160; B = 160 } # Light gray |
| 89 | + } |
| 90 | + } |
| 91 | + 'AccessibleDefault' { |
| 92 | + # Okabe-Ito as-is: a safe general baseline for users unsure of their type. |
| 93 | + @{ |
| 94 | + Error = @{ R = 213; G = 94; B = 0 } # Vermillion |
| 95 | + Warning = @{ R = 230; G = 159; B = 0 } # Orange |
| 96 | + Success = @{ R = 0; G = 158; B = 115 } # Bluish Green |
| 97 | + Info = @{ R = 86; G = 180; B = 233 } # Sky Blue |
| 98 | + Highlight = @{ R = 240; G = 228; B = 66 } # Yellow |
| 99 | + Accent = @{ R = 0; G = 114; B = 178 } # Blue |
| 100 | + Text = @{ R = 0; G = 0; B = 0 } # Black |
| 101 | + Muted = @{ R = 120; G = 120; B = 120 } # Mid-gray |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | +} |
0 commit comments