Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion & color 0D
- call :canvas 50 30
- set "drops=10"
- for /l %%a in (0,1,%drops%) do (
- set /a "s[%%a]=!random! %% 20 + 4)", "l[%%a]=!random! %% 2 + 1"
- set /a "x[%%a]=!random! %% width", "y[%%a]=!random! %% -5 - 6"
- ) 2>nul
- for /l %%0 in (0,1,1000) do (
- for /l %%a in (0,1,%drops%) do (
- set /a "y[%%a]+=s[%%a]", "yl=y[%%a] + l[%%a]"
- call :plotLine x[%%a] y[%%a] x[%%a] yl
- if !y[%%a]! geq %height% (
- set /a "y[%%a]=!random! %% -5 - 6"
- set /a "s[%%a]=!random! %% 20 + 4"
- set /a "x[%%a]=!random! %% width"
- set /a "l[%%a]=!random! %% 2 + 1"
- )
- )
- call :showCanvas
- call :updateCanvas
- )
- exit
- :canvas
- set /a "width=%~1 - 1", "height=%~2 - 1", "conWidth=width + 5", "conHeight=height + 6"
- for /l %%a in (-2,1,%width%) do set "outerBuffer=!outerBuffer!#"
- for /l %%a in (0,1,%width%) do set "widthBuffer=!widthBuffer! "
- call :updateCanvas
- call :cursorpos
- mode con: cols=%conWidth% lines=%conHeight%
- goto :eof
- :updateCanvas
- set "_=-1"
- for /l %%a in (0,1,%height%) do set /a "_+=1" & set "_[!_!]=%widthBuffer%"
- set "_="
- goto :eof
- :showCanvas
- "%temp%\cursorpos.exe" 0 0
- echo. & echo= %outerBuffer%
- for /l %%a in (0,1,%height%) do echo= #!_[%%a]!#
- echo= %outerBuffer%
- goto :eof
- goto :eof
- :plot x y
- setlocal
- set /a "_x2=%~1 + 1"
- (endlocal
- set "_[%~2]=!_[%~2]:~0,%~1!^|!_[%~2]:~%_x2%!"
- )
- goto :eof
- :plotLine x0 y0 x1 y1
- set /a "x0=%~1", "y0=%~2", "x1=%~3", "y1=%~4", "dx=x1 - x0", "dy=y1 - y0"
- if %dy% lss 0 ( set /a "dy=-dy", "stepy=-1" ) else ( set /a "stepy=1")
- if %dx% lss 0 ( set /a "dx=-dx", "stepx=-1" ) else ( set /a "stepx=1")
- set /a "dx<<=1", "dy<<=1"
- if %dx% gtr %dy% (
- set /a "fraction=dy - (dx >> 1)"
- for /l %%x in (%x0%,%stepx%,%x1%) do (
- if !fraction! geq 0 (
- set /a "y0+=stepy"
- set /a "fraction-=dx"
- )
- set /a "fraction+=dy"
- if 0 leq %%x if %%x lss %width% if 0 leq !y0! if !y0! lss %width% (
- call :plot %%x !y0!
- )
- )
- ) else (
- set /a "fraction=dx - (dy >> 1)"
- for /l %%y in (%y0%,%stepy%,%y1%) do (
- if !fraction! geq 0 (
- set /a "x0+=stepx"
- set /a "fraction-=dy"
- )
- set /a "fraction+=dx"
- if 0 leq !x0! if !x0! lss %width% if 0 leq %%y if %%y lss %width% (
- call :plot !x0! %%y
- )
- )
- )
- for %%a in (x0 y0 x1 y1 dx dy stepx stepy fraction) do set "%%a="
- goto :eof
- :: generation of cursorpos.exe, a 3rd party tool to reduce flicker
- :cursorpos
- if not exist "%temp%\cursorpos.exe" (
- for %%a in (
- "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAsAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v"
- "dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABVtbj9EdTWrhHU1q4R1Nau"
- "n8vFrhjU1q7t9MSuE9TWrlJpY2gR1NauAAAAAAAAAABQRQAATAECAOuE4k8AAAAA"
- "AAAAAOAADwELAQUMAAIAAAACAAAAAAAAABAAAAAQAAAAIAAAAABAAAAQAAAAAgAA"
- "BAAAAAAAAAAEAAAAAAAAAAAwAAAAAgAAAAAAAAMAAAAAABAAABAAAAAAEAAAEAAA"
- "AAAAABAAAAAAAAAAAAAAABwgAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAA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biAAAIwgAACcIAAA"
- "uiAAANYgAABgIAAAAAAAAJsARXhpdFByb2Nlc3MA9QBHZXRDb25zb2xlU2NyZWVu"
- "QnVmZmVySW5mbwAAagFHZXRTdGRIYW5kbGUAADgCUmVhZENvbnNvbGVPdXRwdXRD"
- "aGFyYWN0ZXJBAG0CU2V0Q29uc29sZUN1cnNvclBvc2l0aW9uAADmAEdldENvbW1h"
- "bmRMaW5lQQBrZXJuZWwzMi5kbGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- ) do echo %%~a>>cursorpos.txt
- certutil -decode cursorpos.txt %temp%\cursorpos.exe
- del /f /a cursorpos.txt
- )
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement