Page 1 of 2

And now dos batch color secrets?

Posted: 12 Dec 2015 07:35
by einstein1969
Hi to all,

This is my old project for draw a sphere on console using the trick of font Lucida Console size 5 and the "shadow" chars
and the findstr colour mode.

I use an external MATH until a dos batch MATH is not avaible. The SQRT is ready. Lack the EXP/POW at the moments. But my goal is do in "native/pure" mode.

I need discovery a mechanism for create RIGHT colors on console and on image file ( I have open a separated thread )

Antialiasing and dithering ,small fonts usage and unicode use are other goals.

I hope that you can contribute to this work. TIA

Yuo can port in HTA for best view. See Aacini works!

results:
Image

- Use Lucida console font 5
- Disable ClearType
- Enable "Smooth Edges of Screen Fonts"

code:

Code: Select all

@echo off & setlocal EnableDelayedExpansion

rem Use Lucida Console font size 5

rem Version 2.0.9.2 dec-2015
rem by einstein1969
rem http://rosettacode.org/wiki/Draw_a_sphere

mode 90,70
color 0f
pushd "%TMP%"

if not exist FPU-Module.js echo WScript.Stdout.WriteLine(eval(WScript.Stdin.ReadLine().replace(/\x22/g,"")));> FPU-Module.js
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (set "DEL=%%a")
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"

set "color1=778707880880880000000034"
set "color2=FFFFFFF7F7F7777F88788043"
set   "char=Û²²±²°±Û±²°²±°±°Û²°±°  "
set numshadesH=23

set "light[0]=30"
set "light[1]=30"
set "light[2]=-50"

call :normalize2 light

<nul set/p "=%DEL%   °"
call :draw_sphereH2 8 3.5 0.20
call :draw_sphereH2 8 1.5 0.10
call :draw_sphereH2 8 3.5 0.10
call :draw_sphereH2 8 32.0 0.05

del $$$.color.txt
del '

popd

pause

goto :eof

:::::::::::::::::::::::::::::::::::::::::::::::::
:draw_sphereH2 raggio k ambiente

set R=%1
set k=%2
set ambiente=%3

call :calculate2 "Math.floor(-!R!)" floorI
call :calculate2 "Math.ceil(!R!)" CeilI

For /L %%i in (!floorI!,1,!CeilI!) do (

  call :calculate2 "%%i+0.5" x
  call :calculate2 "Math.floor(-2*!R!)" floorJ
  call :calculate2 "Math.ceil(2*!R!)" CeilJ

  For /L %%j in (!floorJ!,1,!ceilJ!) do (

    rem for aspect ratio "(%%j/2+0.5)" = y
    call :calculate2 "!x!*!x! + (%%j/2+0.5)*(%%j/2+0.5) - !R!*!R!" inS

    if "!inS:~0,1!"=="-" (

      call :calculate2 "Math.round( (1 - (Math.pow(Math.max(0,-(!light[0]!*(!x!/Math.sqrt(!x!*!x!+(%%j/2+0.5)*(%%j/2+0.5)+(!R! * !R! -(!x! * !x!) - ((%%j/2+0.5) * (%%j/2+0.5)))))+(!light[1]!)*((%%j/2+0.5)/Math.sqrt(!x!*!x!+(%%j/2+0.5)*(%%j/2+0.5)+(!R! * !R! - (!x! * !x!) - ((%%j/2+0.5) * (%%j/2+0.5)))))+(!light[2]!)*(Math.sqrt(!R! * !R! - (!x! * !x!) - ((%%j/2+0.5) * (%%j/2+0.5)))/Math.sqrt(!x!*!x!+(%%j/2+0.5)*(%%j/2+0.5)+(!R! * !R! - (!x! * !x!) - ((%%j/2+0.5) * (%%j/2+0.5))))))),!k!)+!ambiente!)) * (!numshadesH! - 1) )" intensity
      if "!intensity:~0,1!"=="-" set intensity=0
      if !intensity! geq !numshadesH! set /a intensity=!numshadesH!-1

      title !intensity!
      for %%s in (!intensity!) do call :shadow %%s

    ) else (<nul set/p "=.%DEL%°")

  )

  echo(°
  <nul set/p "=%DEL%   °"
)

goto :eof

::::::::::::::::::::::::::::::::::::::::::::::
:calculate2 expr retvar
  echo "%~1" >%TMP%\in.txt
  Cscript //nologo FPU-Module.js <%TMP%\in.txt >%TMP%\out.txt
  set /p "%2=" <%TMP%\out.txt
  set "%2=!%2:,=.!"
goto :eof

::::::::::::::::::::::::::::::::::::::::::::::::
:normalize2

  set _0=!%1[0]!
  set _1=!%1[1]!
  set _2=!%1[2]!

  call :calculate2 "!_0!/Math.sqrt(!_0!*!_0!+!_1!*!_1!+!_2!*!_2!)" %1[0]
  call :calculate2 "!_1!/Math.sqrt(!_0!*!_0!+!_1!*!_1!+!_2!*!_2!)" %1[1]
  call :calculate2 "!_2!/Math.sqrt(!_0!*!_0!+!_1!*!_1!+!_2!*!_2!)" %1[2]
   
goto :eof

:::::::::::::::::::::::::::::::::::::::::::::::::
:shadow

    (echo !char:~%1,1!\..\'
    ) > $$$.color.txt && findstr /a:!color1:~%1,1!!color2:~%1,1! /f:$$$.color.txt "."

goto :eof


einstein1969

Re: And now dos batch color secrets?

Posted: 15 Dec 2015 04:08
by npocmaka_
Looks great.
Aren't there a way to set the font and its size from command line?

Here are some options for the cmd but not sure if they were only about true type HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console

Re: And now dos batch color secrets?

Posted: 15 Dec 2015 13:30
by einstein1969
There are some examples on setting font for command windows.

In this thread neorobin show an example of use.

Code: Select all

@echo off & setlocal enabledelayedexpansion
mode con cols=80 lines=61 & color 0f & >nul chcp 437

if "%1"=="" (
  for %%a in (  FontSize:00080008
                FontFamily:00000030
                WindowSize:003d0050
                ScreenColors:0000000f
                CodePage:000001b5
                ScreenBufferSize:003d0050
  ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
    >nul reg add HKCU\Console\BadAppleCMD /v %%b /t reg_dword /d 0x%%c /f
  )
  start "BadAppleCMD" /max "%ComSpec%" /c "%~f0" 1&goto:eof

) else ( >nul reg delete HKCU\Console\BadAppleCMD /f )



It is possible then change the default font palette for more complex results!!

Re: And now dos batch color secrets?

Posted: 15 Dec 2015 14:17
by batchcc
Einstein1969 it is not working on my computer; I'm running Windows Vista.

Re: And now dos batch color secrets?

Posted: 10 Jan 2016 22:07
by einstein1969
what type of error?

Re: And now dos batch color secrets?

Posted: 11 Jan 2016 13:54
by batchcc
It gives me this error over and over again.

Code: Select all

░C:\Users\User\AppData\Local\Temp\FPU-Module.js(1, 1) Microsoft JScript runtime error: Au
tomation server can't create object

Re: And now dos batch color secrets?

Posted: 14 Jan 2016 07:52
by Squashman
einstein,
I ran your draw sphere script and now when I run any batch file the Window opens to that same size as yours did.

Re: And now dos batch color secrets?

Posted: 08 Apr 2016 16:04
by einstein1969
batchcc wrote:It gives me this error over and over again.

Code: Select all

░C:\Users\User\AppData\Local\Temp\FPU-Module.js(1, 1) Microsoft JScript runtime error: Au
tomation server can't create object


sorry :oops: but I can't reproduce this errors.

@squashman
You need change something in command windows setting to save new size.

Re: And now dos batch color secrets?

Posted: 08 Apr 2016 18:51
by einstein1969
Finally I release a old work on colors.

- Use Lucida console font 5
- Disable ClearType
- Enable "Smooth Edges of Screen Fonts"

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::
::
:: By einstein1969. ColorsHSV.cmd
::
:: Ver. 0.0.2 09-04-2016 alpha release
::  - Reduce size of environment for speedup.
::  - Auto load Lucida console font size 5
::
:: Ver. 0.0.1 21-10-2013 alpha
::  - Initial version. Too slow to release.
:::::::::::::::::::::::::::::::::::::::::::::
@echo off & setlocal enabledelayedexpansion

mode 90,60
chcp 437

echo Use Lucida console font 5
echo Disable ClearType
echo Enable "Smooth Edges of Screen Fonts"

ping -n 5 localhost >nul

if "%1"=="" (
  for %%a in (  FontSize:00050000
                FontFamily:00000036
                WindowSize:003c005a
                ScreenColors:0000000f
                CodePage:000001b5
                ScreenBufferSize:003c005a
                FontWeight:00000190
  ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
    >nul reg add HKCU\Console\ColorsHSV /v %%b /t reg_dword /d 0x%%c /f
  )
  >nul reg add HKCU\Console\ColorsHSV /v FaceName /t reg_sz /d "Lucida Console" /f
  start "ColorsHSV" /max "%ComSpec%" /c "%~f0" 1&goto:eof

) else ( >nul reg delete HKCU\Console\ColorsHSV /f )


pushd %tmp%

:: prepare for color function
  for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
    set "DEL=%%a"
  )
  <nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"
  <nul > X set /p ".=."


:: Set the 16 color standard palette
  set /a i=0
  for %%c in (   000000 000080 008000 008080 800000 800080 808000 C0C0C0
      808080 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )

  :: gamma 2.2
  set /a i=0
  for %%c in (   000000 000037 003700 003737 370000 370037 373700 898989
      373737 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )


:: Calculate all colors

  set "map=0123456789ABCDEF"

  set cont=-1
  For /L %%i in (0,1,15) do (

   set /a bg=%%i, fg=%%i
   for %%D in (!bg!) do (set bg=!map:~%%D,1!)
        for %%D in (!fg!) do (set fg=!map:~%%D,1!)

   set /a "rgb=0x!p16[%%i]!, rri=rgb >> 16, ggi=(rgb >> 8) & 0xFF, bbi=rgb & 0xFF"

   set /a cont+=1

   set "pRGB!cont!=!p16[%%i]!"

   set "z!cont!=!bg!!fg! !"

   set /a si=%%i+1
      For /L %%j in (!si!,1,15) do (

      set fg=%%j
           for %%D in (!fg!) do (set fg=!map:~%%D,1!)

      set /a "rgb=0x!p16[%%j]!, rrj=rgb >> 16, ggj=(rgb >> 8) & 0xFF, bbj=rgb & 0xFF"

      set /a cont+=1
             set /a "pR=(ddr=rrj-rri)/4+rri, pG=(ddg=ggj-ggi)/4+ggi, pB=(ddb=bbj-bbi)/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!°"
   
           set /a cont+=1
           Set /a "pR=ddr/2+rri, pG=ddg/2+ggi, pB=ddb/2+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!±"

      set /a cont+=1
      Set /a "pR=ddr*3/4+rri, pG=ddg*3/4+ggi, pB=ddb*3/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!²"

   )
  )

  set pal16_4.size=!cont!

  for /L %%i in (0,1,15) do set "p16[%%i]="


  :: Demo of colors. This show HALF number of colors. The WHITE colors are not show!

  Set /a s=10000, v1=10000

  For /L %%h in (0,15,360) do (
   For /L %%v in (10000,-400,0) do call :plot_HSV_RGB %%h !s! %%v
   if !v1! geq 0 (   call :plot 0 0 0
         call :plot 0 0 0
         For /L %%l in (0,8,360) do call :plot_HSV_RGB %%l !s! !v1!
         set /a v1=v1-500 )
   echo(
  )

  echo(

  popd
  pause

exit /b

:::::::::::::::::::::::::::::::::::::::::::
:Plot_HSV_RGB H S V

rem H=0..360 S=0..10000 V=0..10000

set /a H=%1, S=%2, V=%3

rem When 0 <= H < 360, 0 <= S <= 1 and 0 <= V <= 1:

if !H! equ 360 set /a H=0

if !H! lss 0 echo ERROR! & goto :EOF

set /a "h1=h*10000/60, mm = (h1 %% 20000) - 10000"

if !mm! lss 0 set /a mm=-mm

set /a C = (V * S) / 10000

set /a "X = C *(10000 - mm)/10000 , m = V - C"

rem (R,G,B) = (R'+m, G'+m, B'+m)

if !H! lss 60 (set /a R=C+m, G=X+m, B=0+m) else (
   if !H! lss 120 (set /a R=X+m, G=C+m, B=0+m) else (
      if !H! lss 180 (set /a R=0+m, G=C+m, B=X+m) else (
         if !H! lss 240 (set /a R=0+m, G=X+m, B=C+m) else (
            if !H! lss 300 (set /a R=X+m, G=0+m, B=C+m) else (
               if !H! lss 360 (set /a R=C+m, G=0+m, B=X+m) else (echo ERROR!)
            )
         )
      )
   )
)

set /a "R=R*255/10000, G=G*255/10000, B=B*255/10000"

call :Plot !R! !G! !B!

exit /b

:::::::::::::::::::::::::::::::::::::::::::
:plot R G B
  set /a "AArt=%1, AAgt=%2, AAbt=%3"
  set /a dm=256*256*256, fg=-1, bg=-1, ind=-1

  For /L %%i in (0,1,!pal16_4.size!) do (

   set /a "AAArgb=0x!pRGB%%i!, d=(AArt-(AAArgb >> 16))*(AArt-(AAArgb >> 16))+(AAgt-((AAArgb >> 8) & 0xFF))*(AAgt-((AAArgb >> 8) & 0xFF))+(AAbt-(AAArgb & 0xFF))*(AAbt-(AAArgb & 0xFF))"

   if !dm! gtr !d! set /a dm=d, ind=%%i
  )

  for %%i in (!ind!) do (
   set bg=!z%%i:~0,1!
   set fg=!z%%i:~1,1!
   set "char=!z%%i:~2,1!"
  )

  rem Carlos color version 23c. Use for compatibilty with XP
  rem call :color !bg!!fg! "!char!"

  rem jeb version don't work :(
  rem call :color_jeb !bg!!fg! "!char!"

  rem Fast color
  > colorPrint.txt (echo !char!\..\') && findstr /a:!bg!!fg! /f:colorPrint.txt "."

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:RGBhex

set /a "d=pR&15,pR>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pR!) do set "HH=!map:~%%D,1!"

set pRGB=!HH!!LH!

set /a "d=pG&15,pG>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pG!) do set "HH=!map:~%%D,1!"

set pRGB=!pRGB!!HH!!LH!

set /a "d=pB&15,pB>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pB!) do set "HH=!map:~%%D,1!"

set pRGB!cont!=!pRGB!!HH!!LH!

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:color_jeb
set "param=^%~2" !
set "param=!param:"=\"!"
findstr /p /A:%1 "." "!param!\..\X" nul
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
exit /b


result:
Image

I open a separate thread for problem.

einstein1969

Re: And now dos batch color secrets?

Posted: 09 Apr 2016 09:06
by einstein1969
In the previus code is possible work with major resolution decreasing the font size.

This is possible changing for example:

Code: Select all

FontSize:00050000


to:

Code: Select all

FontSize:00020000


This is not possible in standard mode via mouse click and changing the windows propierties.

Einstein1969

Re: And now dos batch color secrets?

Posted: 10 Apr 2016 09:49
by einstein1969
This is with the HSL function. We can view more colors.
I have zoomed than this is little slow. But this is ALPHA stage!!!

- Use Lucida console font 5
- Disable ClearType
- Enable "Smooth Edges of Screen Fonts"

ColorsHSL.cmd:

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::
::
:: By einstein1969. ColorsHSL.cmd
::
:: Ver. 0.0.2 09-04-2016 alpha release
::  - Reduce size of environment for speedup.
::  - Auto load Lucida console font size 5
::
:: Ver. 0.0.1 21-10-2013 alpha
::  - Initial version. Too slow to release.
:::::::::::::::::::::::::::::::::::::::::::::
@echo off & setlocal enabledelayedexpansion

mode 90,60
chcp 437

echo Use Lucida console font 5
echo Disable ClearType
echo Enable "Smooth Edges of Screen Fonts"

ping -n 5 localhost >nul

if "%1"=="" (
  for %%a in (  FontSize:00050000
                FontFamily:00000036
                WindowSize:003c005a
                ScreenColors:0000000f
                CodePage:000001b5
                ScreenBufferSize:003c005a
                FontWeight:00000190
  ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
    >nul reg add HKCU\Console\ColorsHSL /v %%b /t reg_dword /d 0x%%c /f
  )
  >nul reg add HKCU\Console\ColorsHSL /v FaceName /t reg_sz /d "Lucida Console" /f
  start "ColorsHSL" /max "%ComSpec%" /c "%~f0" 1&goto:eof

) else ( >nul reg delete HKCU\Console\ColorsHSL /f )


pushd %tmp%

:: prepare for color function
  for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
    set "DEL=%%a"
  )
  <nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"
  <nul > X set /p ".=."


:: Set the 16 color standard palette
  set /a i=0
  for %%c in (   000000 000080 008000 008080 800000 800080 808000 C0C0C0
      808080 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )

  :: gamma 2.2
  set /a i=0
  for %%c in (   000000 000037 003700 003737 370000 370037 373700 898989
      373737 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )


:: Calculate all colors

  set "map=0123456789ABCDEF"

  set cont=-1
  For /L %%i in (0,1,15) do (

   set /a bg=%%i, fg=%%i
   for %%D in (!bg!) do (set bg=!map:~%%D,1!)
        for %%D in (!fg!) do (set fg=!map:~%%D,1!)

   set /a "rgb=0x!p16[%%i]!, rri=rgb >> 16, ggi=(rgb >> 8) & 0xFF, bbi=rgb & 0xFF"

   set /a cont+=1

   set "pRGB!cont!=!p16[%%i]!"

   set "z!cont!=!bg!!fg! !"

   set /a si=%%i+1
      For /L %%j in (!si!,1,15) do (

      set fg=%%j
           for %%D in (!fg!) do (set fg=!map:~%%D,1!)

      set /a "rgb=0x!p16[%%j]!, rrj=rgb >> 16, ggj=(rgb >> 8) & 0xFF, bbj=rgb & 0xFF"

      set /a cont+=1
             set /a "pR=(ddr=rrj-rri)/4+rri, pG=(ddg=ggj-ggi)/4+ggi, pB=(ddb=bbj-bbi)/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!°"
   
           set /a cont+=1
           Set /a "pR=ddr/2+rri, pG=ddg/2+ggi, pB=ddb/2+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!±"

      set /a cont+=1
      Set /a "pR=ddr*3/4+rri, pG=ddg*3/4+ggi, pB=ddb*3/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!²"

   )
  )

  set pal16_4.size=!cont!

  for /L %%i in (0,1,15) do set "p16[%%i]="


  :: Demo of colors.

  mode 190,120

  For /L %%l in (10000,-100,0) do (
   For /L %%h in (0,2,360) do call :plot_HSL_RGB %%h 10000 %%l
        ping -n 5 localhost >nul
   echo(
  )


  popd
  pause

exit /b

:Plot_HSL_RGB H S L

rem H=0..360 S=0..10000 L=0..10000

set /a H=%1, S=%2, L=%3

rem When 0 <= H < 360, 0 <= S <= 1 and 0 <= L <= 1:

if !H! equ 360 set /a H=0

if !H! lss 0 echo ERROR! & goto :EOF

set /a va=2*L-10000
if !va! lss 0 set /a va=-va

set /a C=(10000-va)*S/10000

set /a "h1=h*10000/60, mm = (h1 %% 20000) - 10000"

if !mm! lss 0 set /a mm=-mm

set /a X = C *(10000 - mm)/10000 , m = L - C/2

rem (R,G,B) = (R'+m, G'+m, B'+m)

if !H! lss 60 (set /a R=C+m, G=X+m, B=0+m) else (
   if !H! lss 120 (set /a R=X+m, G=C+m, B=0+m) else (
      if !H! lss 180 (set /a R=0+m, G=C+m, B=X+m) else (
         if !H! lss 240 (set /a R=0+m, G=X+m, B=C+m) else (
            if !H! lss 300 (set /a R=X+m, G=0+m, B=C+m) else (
               if !H! lss 360 (set /a R=C+m, G=0+m, B=X+m) else (echo ERROR!)
            )
         )
      )
   )
)

set /a R=R*255/10000, G=G*255/10000, B=B*255/10000

call :Plot !R! !G! !B!

goto :eof

:::::::::::::::::::::::::::::::::::::::::::
:plot R G B
  set /a "AArt=%1, AAgt=%2, AAbt=%3"
  set /a dm=256*256*256, fg=-1, bg=-1, ind=-1

  For /L %%i in (0,1,!pal16_4.size!) do (

   set /a "AAArgb=0x!pRGB%%i!, d=(AArt-(AAArgb >> 16))*(AArt-(AAArgb >> 16))+(AAgt-((AAArgb >> 8) & 0xFF))*(AAgt-((AAArgb >> 8) & 0xFF))+(AAbt-(AAArgb & 0xFF))*(AAbt-(AAArgb & 0xFF))"

   if !dm! gtr !d! set /a dm=d, ind=%%i
  )

  for %%i in (!ind!) do (
   set bg=!z%%i:~0,1!
   set fg=!z%%i:~1,1!
   set "char=!z%%i:~2,1!"
  )

  rem Carlos color version 23c. Use for compatibilty with XP
  rem call :color !bg!!fg! "!char!"

  rem jeb version don't work :(
  rem call :color_jeb !bg!!fg! "!char!"

  rem Fast color
  > colorPrint.txt (echo !char!\..\') && findstr /a:!bg!!fg! /f:colorPrint.txt "."

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:RGBhex

set /a "d=pR&15,pR>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pR!) do set "HH=!map:~%%D,1!"

set pRGB=!HH!!LH!

set /a "d=pG&15,pG>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pG!) do set "HH=!map:~%%D,1!"

set pRGB=!pRGB!!HH!!LH!

set /a "d=pB&15,pB>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pB!) do set "HH=!map:~%%D,1!"

set pRGB!cont!=!pRGB!!HH!!LH!

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:color_jeb
set "param=^%~2" !
set "param=!param:"=\"!"
findstr /p /A:%1 "." "!param!\..\X" nul
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
exit /b



results:
Image

einstein1969

Re: And now dos batch color secrets?

Posted: 10 Apr 2016 10:41
by foxidrive
Nice! That's so impressive, when back many years ago it would have been considered impossible.

Others have done nice work that I've noticed with colour too, real purdy.

Re: And now dos batch color secrets?

Posted: 10 Apr 2016 10:45
by einstein1969
This is the RGB CUBE but on 2D plane.
This show all color in the R G B range.

- Use Lucida console font 5
- Disable ClearType
- Enable "Smooth Edges of Screen Fonts"

ColorsRGB.cmd:

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::
::
:: By einstein1969. ColorsRGB.cmd
::
:: Ver. 0.0.2 09-04-2016 alpha release
::  - Reduce size of environment for speedup.
::  - Auto load Lucida console font size 5
::
:: Ver. 0.0.1 21-10-2013 alpha
::  - Initial version. Too slow to release.
:::::::::::::::::::::::::::::::::::::::::::::
@echo off & setlocal enabledelayedexpansion

mode 90,60
chcp 437

echo Use Lucida console font 5
echo Disable ClearType
echo Enable "Smooth Edges of Screen Fonts"

ping -n 5 localhost >nul

if "%1"=="" (
  for %%a in (  FontSize:00050000
                FontFamily:00000036
                WindowSize:003c005a
                ScreenColors:0000000f
                CodePage:000001b5
                ScreenBufferSize:003c005a
                FontWeight:00000190
  ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
    >nul reg add HKCU\Console\ColorsRGB /v %%b /t reg_dword /d 0x%%c /f
  )
  >nul reg add HKCU\Console\ColorsRGB /v FaceName /t reg_sz /d "Lucida Console" /f
  start "ColorsRGB" /max "%ComSpec%" /c "%~f0" 1&goto:eof

) else ( >nul reg delete HKCU\Console\ColorsRGB /f )


pushd %tmp%

:: prepare for color function
  for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
    set "DEL=%%a"
  )
  <nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"
  <nul > X set /p ".=."


:: Set the 16 color standard palette
  set /a i=0
  for %%c in (   000000 000080 008000 008080 800000 800080 808000 C0C0C0
      808080 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )

  :: gamma 2.2
  set /a i=0
  for %%c in (   000000 000037 003700 003737 370000 370037 373700 898989
      373737 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )


:: Calculate all colors

  set "map=0123456789ABCDEF"

  set cont=-1
  For /L %%i in (0,1,15) do (

   set /a bg=%%i, fg=%%i
   for %%D in (!bg!) do (set bg=!map:~%%D,1!)
        for %%D in (!fg!) do (set fg=!map:~%%D,1!)

   set /a "rgb=0x!p16[%%i]!, rri=rgb >> 16, ggi=(rgb >> 8) & 0xFF, bbi=rgb & 0xFF"

   set /a cont+=1

   set "pRGB!cont!=!p16[%%i]!"

   set "z!cont!=!bg!!fg! !"

   set /a si=%%i+1
      For /L %%j in (!si!,1,15) do (

      set fg=%%j
           for %%D in (!fg!) do (set fg=!map:~%%D,1!)

      set /a "rgb=0x!p16[%%j]!, rrj=rgb >> 16, ggj=(rgb >> 8) & 0xFF, bbj=rgb & 0xFF"

      set /a cont+=1
             set /a "pR=(ddr=rrj-rri)/4+rri, pG=(ddg=ggj-ggi)/4+ggi, pB=(ddb=bbj-bbi)/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!°"
   
           set /a cont+=1
           Set /a "pR=ddr/2+rri, pG=ddg/2+ggi, pB=ddb/2+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!±"

      set /a cont+=1
      Set /a "pR=ddr*3/4+rri, pG=ddg*3/4+ggi, pB=ddb*3/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!²"

   )
  )

  set pal16_4.size=!cont!

  for /L %%i in (0,1,15) do set "p16[%%i]="


  :: Demo of colors.

  set /a v=1, st1=32*v, st2=16*v, mst2=-st2, mst1=-st1

  for /L %%b in (0,!st1!,256) do (
   for /L %%i in (256,!mst2!,0) do call :plot 0 %%i %%b
   echo(
  )

  for /L %%r in (0,!st1!,256) do (
   for /L %%i in (256,!mst2!,0) do call :plot %%r %%i 255
   for /L %%b in (256,!mst2!,0) do call :plot %%r 0 %%b
   for /L %%g in (0,!st2!,256) do call :plot %%r %%g 0
   for /L %%i in (0,!st2!,256) do call :plot %%r 255 %%i
   echo(
  )
  for /L %%b in (256,!mst1!,0) do (
   for /L %%g in (256,!mst2!,0) do call :plot 255 %%g %%b
   echo(
  )

  popd
  pause

exit /b

:::::::::::::::::::::::::::::::::::::::::::
:plot R G B
  set /a "AArt=%1, AAgt=%2, AAbt=%3"
  set /a dm=256*256*256, fg=-1, bg=-1, ind=-1

  For /L %%i in (0,1,!pal16_4.size!) do (

   set /a "AAArgb=0x!pRGB%%i!, d=(AArt-(AAArgb >> 16))*(AArt-(AAArgb >> 16))+(AAgt-((AAArgb >> 8) & 0xFF))*(AAgt-((AAArgb >> 8) & 0xFF))+(AAbt-(AAArgb & 0xFF))*(AAbt-(AAArgb & 0xFF))"

   if !dm! gtr !d! set /a dm=d, ind=%%i
  )

  for %%i in (!ind!) do (
   set bg=!z%%i:~0,1!
   set fg=!z%%i:~1,1!
   set "char=!z%%i:~2,1!"
  )

  rem Carlos color version 23c. Use for compatibilty with XP
  rem call :color !bg!!fg! "!char!"

  rem jeb version don't work :(
  rem call :color_jeb !bg!!fg! "!char!"

  rem Fast color
  > colorPrint.txt (echo !char!\..\') && findstr /a:!bg!!fg! /f:colorPrint.txt "."

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:RGBhex

set /a "d=pR&15,pR>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pR!) do set "HH=!map:~%%D,1!"

set pRGB=!HH!!LH!

set /a "d=pG&15,pG>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pG!) do set "HH=!map:~%%D,1!"

set pRGB=!pRGB!!HH!!LH!

set /a "d=pB&15,pB>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pB!) do set "HH=!map:~%%D,1!"

set pRGB!cont!=!pRGB!!HH!!LH!

exit/b

:::::::::::::::::::::::::::::::::::::::::::
:color_jeb
set "param=^%~2" !
set "param=!param:"=\"!"
findstr /p /A:%1 "." "!param!\..\X" nul
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
exit /b



result:
Image

einstein1969

Re: And now dos batch color secrets?

Posted: 10 Apr 2016 10:49
by einstein1969
foxidrive wrote:Nice! That's so impressive, when back many years ago it would have been considered impossible.

Others have done nice work that I've noticed with colour too, real purdy.


Thanks foxidrive,
do you have code, links ?

Re: And now dos batch color secrets?

Posted: 10 Apr 2016 13:11
by foxidrive
I can hardly remember my own name einstein! :)

I pretty sure Antonio was doing some work on it, and now I'm put on the spot I can't recall stuff.