Advertisement
IcarusLives

Purple Rain animation - Prince tribute

Mar 11th, 2017
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.49 KB | None | 0 0
  1. @echo off & setlocal enableDelayedExpansion & color 0D
  2. call :canvas 50 30
  3.  
  4. set "drops=10"
  5. for /l %%a in (0,1,%drops%) do (
  6.     set /a "s[%%a]=!random! %% 20 + 4)", "l[%%a]=!random! %%  2 + 1"
  7.     set /a "x[%%a]=!random! %% width",   "y[%%a]=!random! %% -5 - 6"
  8. ) 2>nul
  9.  
  10. for /l %%0 in (0,1,1000) do (
  11.  
  12.     for /l %%a in (0,1,%drops%) do (
  13.    
  14.         set /a "y[%%a]+=s[%%a]", "yl=y[%%a] + l[%%a]"
  15.        
  16.         call :plotLine x[%%a] y[%%a] x[%%a] yl
  17.        
  18.         if !y[%%a]! geq %height% (
  19.             set /a "y[%%a]=!random! %% -5 - 6"
  20.             set /a "s[%%a]=!random! %% 20 + 4"
  21.             set /a "x[%%a]=!random! %% width"
  22.             set /a "l[%%a]=!random! %% 2 + 1"
  23.         )
  24.     )
  25.  
  26.     call :showCanvas
  27.     call :updateCanvas
  28. )
  29. exit
  30.  
  31. :canvas
  32.         set /a "width=%~1 - 1", "height=%~2 - 1", "conWidth=width + 5", "conHeight=height + 6"
  33.         for /l %%a in (-2,1,%width%) do set "outerBuffer=!outerBuffer!#"
  34.         for /l %%a in (0,1,%width%)  do set "widthBuffer=!widthBuffer! "
  35.         call :updateCanvas
  36.         call :cursorpos
  37.         mode con: cols=%conWidth% lines=%conHeight%
  38.     goto :eof
  39.    
  40.     :updateCanvas
  41.         set "_=-1"
  42.             for /l %%a in (0,1,%height%) do set /a "_+=1" & set "_[!_!]=%widthBuffer%"
  43.         set "_="
  44.     goto :eof
  45.    
  46.     :showCanvas
  47.         "%temp%\cursorpos.exe" 0 0
  48.         echo. & echo= %outerBuffer%
  49.         for /l %%a in (0,1,%height%) do echo= #!_[%%a]!#
  50.         echo= %outerBuffer%
  51.     goto :eof
  52. goto :eof
  53.  
  54. :plot x y
  55.     setlocal
  56.         set /a "_x2=%~1 + 1"
  57.         (endlocal
  58.             set "_[%~2]=!_[%~2]:~0,%~1!^|!_[%~2]:~%_x2%!"
  59.         )
  60. goto :eof
  61.  
  62. :plotLine x0 y0 x1 y1
  63.     set /a "x0=%~1", "y0=%~2", "x1=%~3", "y1=%~4", "dx=x1 - x0", "dy=y1 - y0"
  64.    
  65.     if %dy% lss 0 ( set /a "dy=-dy", "stepy=-1" ) else ( set /a "stepy=1")
  66.     if %dx% lss 0 ( set /a "dx=-dx", "stepx=-1" ) else ( set /a "stepx=1")
  67.    
  68.     set /a "dx<<=1", "dy<<=1"
  69.  
  70.     if %dx% gtr %dy% (
  71.         set /a "fraction=dy - (dx >> 1)"
  72.         for /l %%x in (%x0%,%stepx%,%x1%) do (
  73.             if !fraction! geq 0 (
  74.                 set /a "y0+=stepy"
  75.                 set /a "fraction-=dx"
  76.             )
  77.             set /a "fraction+=dy"
  78.             if 0 leq %%x if %%x lss %width% if 0 leq !y0! if !y0! lss %width% (
  79.                 call :plot %%x !y0!
  80.             )
  81.         )
  82.     ) else (
  83.         set /a "fraction=dx - (dy >> 1)"
  84.         for /l %%y in (%y0%,%stepy%,%y1%) do (
  85.             if !fraction! geq 0 (
  86.                 set /a "x0+=stepx"
  87.                 set /a "fraction-=dy"
  88.             )
  89.             set /a "fraction+=dx"
  90.             if 0 leq !x0! if !x0! lss %width% if 0 leq %%y if %%y lss %width% (
  91.                 call :plot !x0! %%y
  92.             )
  93.         )
  94.     )
  95.     for %%a in (x0 y0 x1 y1 dx dy stepx stepy fraction) do set "%%a="
  96. goto :eof
  97.  
  98.  
  99. :: generation of cursorpos.exe, a 3rd party tool to reduce flicker
  100. :cursorpos
  101. if not exist "%temp%\cursorpos.exe" (
  102.     for %%a in (
  103.         "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  104.         "AAAAAAAAAAAAAAAAsAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v"
  105.         "dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABVtbj9EdTWrhHU1q4R1Nau"
  106.         "n8vFrhjU1q7t9MSuE9TWrlJpY2gR1NauAAAAAAAAAABQRQAATAECAOuE4k8AAAAA"
  107.         "AAAAAOAADwELAQUMAAIAAAACAAAAAAAAABAAAAAQAAAAIAAAAABAAAAQAAAAAgAA"
  108.         "BAAAAAAAAAAEAAAAAAAAAAAwAAAAAgAAAAAAAAMAAAAAABAAABAAAAAAEAAAEAAA"
  109.         "AAAAABAAAAAAAAAAAAAAABwgAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  110.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  111.         "AAAAAAAAAAAAIAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAA"
  112.         "QgEAAAAQAAAAAgAAAAIAAAAAAAAAAAAAAAAAACAAAGAucmRhdGEAAPYAAAAAIAAA"
  113.         "AAIAAAAEAAAAAAAAAAAAAAAAAABAAABAAAAAAAAAAADoBgAAAFDoEwEAAFWL7IPE"
  114.         "4Gr16BIBAACJRfyNReZQ/3X86P0AAABmi0XsZolF5Oi8AAAA6NsAAACAPgB1BYtF"
  115.         "6utcgD49dQZG6MYAAABmi03q6EoAAACJRerotQAAAIA+AHQYgD4sdQZG6KUAAABm"
  116.         "i03k6CkAAABmiUXsi13qU/91/OiuAAAAjUXmUFNqAY1F41D/dfzolQAAAA+2RePJ"
  117.         "wzPAMtsz0ooWRoD6K3QIgPotdQmAywKAywGKFkaA+jByD4D6OXcKgOowa8AKA8Lr"
  118.         "6fbDAXQL9sMCdANm99hmA8FOw8zMzMzMzMzMzMzMzMzoRwAAAIvwigZGPCJ1CYoG"
  119.         "RjwidfnrDIoGRjwgdASEwHX1TsOKBkY8IHT5TsPM/yUUIEAA/yUAIEAA/yUEIEAA"
  120.         "/yUIIEAA/yUMIEAA/yUQIEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  121.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  122.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  123.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  124.         "AAAAAAAAAAAAAAAAAAAAAG4gAACMIAAAnCAAALogAADWIAAAYCAAAAAAAABEIAAA"
  125.         "AAAAAAAAAADoIAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbiAAAIwgAACcIAAA"
  126.         "uiAAANYgAABgIAAAAAAAAJsARXhpdFByb2Nlc3MA9QBHZXRDb25zb2xlU2NyZWVu"
  127.         "QnVmZmVySW5mbwAAagFHZXRTdGRIYW5kbGUAADgCUmVhZENvbnNvbGVPdXRwdXRD"
  128.         "aGFyYWN0ZXJBAG0CU2V0Q29uc29sZUN1cnNvclBvc2l0aW9uAADmAEdldENvbW1h"
  129.         "bmRMaW5lQQBrZXJuZWwzMi5kbGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  130.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  131.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  132.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  133.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  134.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  135.     ) do echo %%~a>>cursorpos.txt
  136.    
  137.     certutil -decode cursorpos.txt %temp%\cursorpos.exe
  138.     del /f /a cursorpos.txt
  139. )
  140. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement