1) Indices 0x00 - 0x0F contain the most non-linear part:
Code: Select all
( 0, 0, 0),
(128, 0, 0),
( 0, 128, 0),
(128, 128, 0),
( 0, 0, 128),
(128, 0, 128),
( 0, 128, 128),
(192, 192, 192),
(128, 128, 128),
(255, 0, 0),
( 0, 255, 0),
(255, 255, 0),
( 0, 0, 255),
(255, 0, 255),
( 0, 255, 255),
(255, 255, 255)
Code: Select all
( 0, 0, 0), ( 0, 0, 95), ( 0, 0, 135), ( 0, 0, 175), ( 0, 0, 215), ( 0, 0, 255),
( 0, 95, 0), ( 0, 95, 95), ( 0, 95, 135), ( 0, 95, 175), ( 0, 95, 215), ( 0, 95, 255),
( 0, 135, 0), ( 0, 135, 95), ( 0, 135, 135), ( 0, 135, 175), ( 0, 135, 215), ( 0, 135, 255),
( 0, 175, 0), ( 0, 175, 95), ( 0, 175, 135), ( 0, 175, 175), ( 0, 175, 215), ( 0, 175, 255),
( 0, 215, 0), ( 0, 215, 95), ( 0, 215, 135), ( 0, 215, 175), ( 0, 215, 215), ( 0, 215, 255),
( 0, 255, 0), ( 0, 255, 95), ( 0, 255, 135), ( 0, 255, 175), ( 0, 255, 215), ( 0, 255, 255),
( 95, 0, 0), ( 95, 0, 95), ( 95, 0, 135), ( 95, 0, 175), ( 95, 0, 215), ( 95, 0, 255),
( 95, 95, 0), ( 95, 95, 95), ( 95, 95, 135), ( 95, 95, 175), ( 95, 95, 215), ( 95, 95, 255),
( 95, 135, 0), ( 95, 135, 95), ( 95, 135, 135), ( 95, 135, 175), ( 95, 135, 215), ( 95, 135, 255),
( 95, 175, 0), ( 95, 175, 95), ( 95, 175, 135), ( 95, 175, 175), ( 95, 175, 215), ( 95, 175, 255),
( 95, 215, 0), ( 95, 215, 95), ( 95, 215, 135), ( 95, 215, 175), ( 95, 215, 215), ( 95, 215, 255),
( 95, 255, 0), ( 95, 255, 95), ( 95, 255, 135), ( 95, 255, 175), ( 95, 255, 215), ( 95, 255, 255),
(135, 0, 0), (135, 0, 95), (135, 0, 135), (135, 0, 175), (135, 0, 215), (135, 0, 255),
(135, 95, 0), (135, 95, 95), (135, 95, 135), (135, 95, 175), (135, 95, 215), (135, 95, 255),
(135, 135, 0), (135, 135, 95), (135, 135, 135), (135, 135, 175), (135, 135, 215), (135, 135, 255),
(135, 175, 0), (135, 175, 95), (135, 175, 135), (135, 175, 175), (135, 175, 215), (135, 175, 255),
(135, 215, 0), (135, 215, 95), (135, 215, 135), (135, 215, 175), (135, 215, 215), (135, 215, 255),
(135, 255, 0), (135, 255, 95), (135, 255, 135), (135, 255, 175), (135, 255, 215), (135, 255, 255),
(175, 0, 0), (175, 0, 95), (175, 0, 135), (175, 0, 175), (175, 0, 215), (175, 0, 255),
(175, 95, 0), (175, 95, 95), (175, 95, 135), (175, 95, 175), (175, 95, 215), (175, 95, 255),
(175, 135, 0), (175, 135, 95), (175, 135, 135), (175, 135, 175), (175, 135, 215), (175, 135, 255),
(175, 175, 0), (175, 175, 95), (175, 175, 135), (175, 175, 175), (175, 175, 215), (175, 175, 255),
(175, 215, 0), (175, 215, 95), (175, 215, 135), (175, 215, 175), (175, 215, 215), (175, 215, 255),
(175, 255, 0), (175, 255, 95), (175, 255, 135), (175, 255, 175), (175, 255, 215), (175, 255, 255),
(215, 0, 0), (215, 0, 95), (215, 0, 135), (215, 0, 175), (215, 0, 215), (215, 0, 255),
(215, 95, 0), (215, 95, 95), (215, 95, 135), (215, 95, 175), (215, 95, 215), (215, 95, 255),
(215, 135, 0), (215, 135, 95), (215, 135, 135), (215, 135, 175), (215, 135, 215), (215, 135, 255),
(215, 175, 0), (215, 175, 95), (215, 175, 135), (215, 175, 175), (215, 175, 215), (215, 175, 255),
(215, 215, 0), (215, 215, 95), (215, 215, 135), (215, 215, 175), (215, 215, 215), (215, 215, 255),
(215, 255, 0), (215, 255, 95), (215, 255, 135), (215, 255, 175), (215, 255, 215), (215, 255, 255),
(255, 0, 0), (255, 0, 95), (255, 0, 135), (255, 0, 175), (255, 0, 215), (255, 0, 255),
(255, 95, 0), (255, 95, 95), (255, 95, 135), (255, 95, 175), (255, 95, 215), (255, 95, 255),
(255, 135, 0), (255, 135, 95), (255, 135, 135), (255, 135, 175), (255, 135, 215), (255, 135, 255),
(255, 175, 0), (255, 175, 95), (255, 175, 135), (255, 175, 175), (255, 175, 215), (255, 175, 255),
(255, 215, 0), (255, 215, 95), (255, 215, 135), (255, 215, 175), (255, 215, 215), (255, 215, 255),
(255, 255, 0), (255, 255, 95), (255, 255, 135), (255, 255, 175), (255, 255, 215), (255, 255, 255),
Code: Select all
( 8, 8, 8), ( 18, 18, 18), ( 28, 28, 28), ( 38, 38, 38), ( 48, 48, 48),
( 58, 58, 58), ( 68, 68, 68), ( 78, 78, 78), ( 88, 88, 88), ( 98, 98, 98),
(108, 108, 108), (118, 118, 118), (128, 128, 128), (138, 138, 138), (148, 148, 148),
(158, 158, 158), (168, 168, 168), (178, 178, 178), (188, 188, 188), (198, 198, 198),
(208, 108, 108), (218, 218, 218), (228, 228, 228), (238, 238, 238)
Code: Select all
set /A "%4=(((%1)-35)/40)*36 + (((%2)-35)/40)*6 + ((%3)-35)/40 + 0x10"
Code: Select all
set /a "%4=0xE8+(((0x3FF*((((%1)+(%2)+(%3)+297)&0x400)>>10))|(((%1)+(%2)+(%3)+297)&0x3FF))-306)/30"
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
rem save in UTF8
chcp 65001
cls
for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
set "delta=20"
set "RGB_max=255"
set "start=15"
set "blueSlice=15"
::set "start=15"
::set "delta=10"
::set "blueSlice=175"
::for %%b in (%blueSlice%) do (
for /l %%b in (%start%, %delta%, %RGB_max%) do (
echo(
echo(slice blue=%%~b; left correct rgb values; right: color map
for /l %%g in (%start%, %delta%, %RGB_max%) do (
for /l %%r in (%start%, %delta%, %RGB_max%) do (
<nul set/p =%ESC%[38;2;%%~r;%%~g;%%~bm██
)
<nul set/p "=%ESC%[38;5;7m %ESC%[38;5;7m"
for /l %%r in (%start%, %delta%, %RGB_max%) do (
set /a "gray=(%%~r+%%~g+%%~b)/3"
<nul set/p =%ESC%[38;2;!gray!;!gray!;!gray!m██
)
<nul set/p "=%ESC%[38;5;7m %ESC%[38;5;7m"
for /l %%r in (%start%, %delta%, %RGB_max%) do (
call :to256 %%~r %%~g %%~b C
<nul set/p =%ESC%[38;5;!C!m██
)
<nul set/p "=%ESC%[38;5;7m %ESC%[38;5;7m"
for /l %%r in (%start%, %delta%, %RGB_max%) do (
call :toGray %%~r %%~g %%~b C
<nul set/p =%ESC%[38;5;!C!m██
)
echo(%ESC%[38;5;7m
)
)
echo(
echo(=======
)
echo(
:: >nul pause
goto :eof
:to256 R G B return var
set /A "%4=(((%1)-35)/40)*36 + (((%2)-35)/40)*6 + ((%3)-35)/40 + 0x10"
goto :eof
:toGray R G B return var
set /a "%4=0xE8+(((0x3FF*((((%1)+(%2)+(%3)+297)&0x400)>>10))|(((%1)+(%2)+(%3)+297)&0x3FF))-306)/30"
goto :eof
Sidenote:
For a correct mapping to all values, you need to compute the best fit for all those pieces and select the best out of those.
penpen
Edit 1: Added the simplest linear grayscale method.
Edit 2: Added the rgb grayscale for comparison, also rmoved an error.