Advertisement
Aacini

T2H - Aacini's Colors Tree.bat

Nov 20th, 2013
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3.  
  4. rem "Aacini's Colors Tree.bat": Create a safe color palette in the form of a Tree
  5. rem Original design by Antonio Perez Ayala
  6.  
  7. rem Define the digits
  8. set base=-1
  9. for %%a in (00 33 66 99 CC FF) do (
  10.    set /A base+=1
  11.    set digit[!base!]=%%a
  12. )
  13. set /A baseM1=base-1
  14.  
  15. rem Define the trunk
  16. for /L %%b in (%base%,-1,0) do (
  17.    set a=%base%
  18.    for /L %%a in (%base%,-1,0) do (
  19.       if %%a neq %%b (
  20.          set trunk[!a!][%%b]=!digit[%%a]!!digit[%%b]!!digit[%%a]!
  21.          set /A a-=1
  22.       )
  23.    )
  24. )
  25.  
  26. rem Generate the tree
  27. (
  28. echo =
  29. echo [table align="center" cellpadding="3"]
  30. set trunkHeight=1
  31. for /L %%a in (%base%,-1,1) do set /A A=%%a-1 & for /F %%A in ("!A!") do (
  32.  
  33.    rem Trunk with no branches
  34.    set "line="
  35.    for /L %%i in (1,1,%base%) do set "line=!line![rowspan="!trunkHeight!"][nbsp]|"
  36.    set value=!digit[%%a]!!digit[%%a]!!digit[%%a]!
  37.    echo !line![rowspan="!trunkHeight!" bgcolor="#!value!"]!value!
  38.    for /L %%i in (2,1,!trunkHeight!) do echo [nbsp]
  39.    set /A trunkHeight+=1
  40.  
  41.    rem Bunch of branches
  42.    for /L %%b in (%base%,-1,0) do (
  43.       set "line="
  44.       rem Left margin
  45.       for /L %%i in (%%a,1,%baseM1%) do set "line=!line![nbsp]|"
  46.       rem Left branch
  47.       for /L %%c in (0,1,%%A) do (
  48.          set value=!digit[%%a]!!digit[%%b]!!digit[%%c]!
  49.          set "line=!line![bgcolor="#!value!"]!value!|"
  50.       )
  51.       rem Trunk with branches
  52.       set value=!trunk[%%a][%%b]!
  53.       set line=!line![bgcolor="#!value!"]!value!
  54.       rem Right branch
  55.       for /L %%c in (%%A,-1,0) do (
  56.          set value=!digit[%%c]!!digit[%%b]!!digit[%%a]!
  57.          set "line=!line!|[bgcolor="#!value!"]!value!"
  58.       )
  59.       echo !line!
  60.    )
  61.  
  62. )
  63.  
  64. rem Bottom trunk
  65. set "line="
  66. for /L %%i in (1,1,%base%) do set "line=!line![rowspan="!trunkHeight!"][nbsp]|"
  67. set value=!digit[0]!!digit[0]!!digit[0]!
  68. echo !line![rowspan="!trunkHeight!" bgcolor="#!value!"][color="white"]!value![/color]
  69. for /L %%i in (2,1,!trunkHeight!) do echo [nbsp]
  70. echo [/table]
  71.  
  72. echo [color="#999999" size="-1"]Original design by Antonio Pérez Ayala[/color]
  73. echo [hr]
  74. echo [code:"Aacini's Colors Tree.bat" height:26em;]Aacini's Colors Tree.bat
  75. set /P "=[" < NUL
  76. echo /code]
  77. ) > "Aacini's Colors Tree.txt"
  78.  
  79. TextToHtml "Aacini's Colors Tree.txt" /N
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement