IcarusLives

Library.bat

Sep 1st, 2021 (edited)
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 31.87 KB | None | 0 0
  1. (call :buildSketch) & exit
  2. :revision
  3.     echo Checking Revision...
  4.     set "revision=3.29.2"
  5.     set "libraryError=False"
  6.     for /f "tokens=4-5 delims=. " %%i in ('ver') do set "winVERSION=%%i.%%j"
  7.     if %revision:.=% lss %revisionRequired:.=% (
  8.         echo Updated Library.bat Required
  9.         set "libraryError=True"
  10.     )
  11.     if "%winversion%" neq "10.0" (
  12.         echo %~n0 is not supported on this version of Windows: %winVERSION%"
  13.         set "libraryError=True"
  14.     )
  15.     if "%libraryError%" equ "True" (
  16.         ren "%~nx0" "Library.bat"
  17.         ren "temp.bat" "%self%"
  18.         del /f /q "temp.bat"
  19.         timeout /t 3 & exit
  20.     )
  21. goto :eof
  22. :StdLib %~1=wid %~2=hei %~3=fontSize %~3=/debug
  23. title Windows Batch Library - Revision: %Revision%
  24. REM ESC
  25. set "esc="
  26. set "\e="
  27.      echo.&
  28. echo %\e%E%\e%EGetting things started...
  29. set "debugC1=%~1" & set "debugC2=%~3" & set "debug=False"
  30. for %%d in (1 2) do if "!debugC%%d!" equ "/debug" (
  31.     set "debug=True"
  32. )
  33. if "%~3" neq "" (
  34.     set "defaultFontSize=%~3"
  35. ) else (
  36.     set "defaultFontSize=12"
  37. )
  38.  
  39. if "%debug%" equ "True" (
  40.     @echo on
  41.     call :setfont 16 Consolas
  42.     call :size 180 100
  43. ) else (
  44.     call :setfont %defaultFontSize% "Terminal"
  45.     call :size %~1 %~2
  46. )
  47. REM "pixel"
  48. set "pixel=Û"
  49. REM (for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" )
  50. <nul set /p "=!esc![?25l"
  51. REM VT100 ready -rgb
  52. set "-rgb=^!r^!;^!g^!;^!b^!"
  53. REM new clear screen variable execute with echo %cls% or <nul set /p "=%cls%"
  54. set "cls=%esc%[2J"
  55. set "\c=%esc%[2J"
  56.  
  57. if /i "%~3" equ "/extlib" (
  58.     rem Backspace
  59.     for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
  60.     rem BEL (sound)
  61.     for /f %%i in ('forfiles /m "%~nx0" /c "cmd /c echo 0x07"') do set "BEL=%%i"
  62.     rem Carriage Return  0x0D  decimal 13
  63.     for /f %%A in ('copy /z "%~dpf0" nul') do set "CR=%%A"
  64.     rem Tab 0x09
  65.     for /f "delims=" %%T in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x09"') do set "TAB=%%T"
  66. )
  67. goto :eof
  68.  
  69. :size
  70. if "%~2" equ "" goto :eof
  71. set /a "wid=%~1, hei=%~2"
  72. mode !wid!,!hei!
  73. goto :eof
  74.  
  75. :setFont
  76. if "%~2" equ "" goto :eof
  77. call :init_setfont
  78. %setFont% %~1 %~2
  79. goto :eof
  80.  
  81. :cursor
  82. echo Loading Cursor macros...
  83. set "push=<nul set /p "=%esc%7""
  84. set "pop=<nul set /p "=%esc%8""
  85. set "cursor[U]=<nul set /p "=%esc%[?A""
  86. set "cursor[D]=<nul set /p "=%esc%[?B""
  87. set "cursor[L]=<nul set /p "=%esc%[?C""
  88. set "cursor[R]=<nul set /p "=%esc%[?D""
  89. set "cac=%esc%[1J"
  90. set "cbc=%esc%[0J"
  91. set "underLine=%esc%[4m"
  92. set "capIt=%esc%[0m"
  93. set "\nl=%esc%E"
  94. set "moveXY=set /a "cursorX=x", "cursorY=y" ^& <nul set /p "=%esc%[^^!y^^!;^^!x^^!H""
  95. goto :eof
  96. :math
  97. echo Loading Math macros...
  98. set /a "PI=(35500000/113+5)/10, HALF_PI=(35500000/113/2+5)/10, TWO_PI=2*PI, PI32=PI+PI_div_2, neg_PI=PI * -1, neg_HALF_PI=HALF_PI *-1"
  99. set "_SIN=a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000"
  100. set "sin=(a=(x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  101. set "cos=(a=(15708 - x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  102. set "sinr=(a=(x)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  103. set "cosr=(a=(15708 - x)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  104. set "Sqrt(N)=( x=(N)/(11*1024)+40, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2 )"
  105. set "Sign=1 / (x & 1)"
  106. set "Abs=(((x)>>31|1)*(x))"
  107. set "dist(x2,x1,y2,y1)=( @=x2-x1, $=y2-y1, ?=(((@>>31|1)*@-(($>>31|1)*$))>>31)+1, ?*(2*(@>>31|1)*@-($>>31|1)*$-((@>>31|1)*@-($>>31|1)*$)) + ^^^!?*((@>>31|1)*@-($>>31|1)*$-((@>>31|1)*@-($>>31|1)*$*2)) )"
  108. set "avg=(x&y)+(x^y)/2"
  109. goto :eof
  110. :misc
  111. echo Loading Misc. macros...
  112. set "rndsign=$o=(^!random^!%%3+-1),out=(((((~(0-$o)>>31)&1)&((~($o-0)>>31)&1))*($o+def))|((~(((~(0-$o)>>31)&1)&((~($o-0)>>31)&1))&1)*($o*num)))"
  113. set "gravity=grav=1, a#+=grav, v#+=a#, a#*=0, #+=v#"
  114. set "swap(x,y)=t=x, x=y, y=t"
  115. set "getState=a*8+b*4+c*2+d*1"
  116. set "map=x2+(y2-x2)*(v-x1)/(y1-x1)"
  117. set "map=(c)+((d)-(c))*((v)-(a))/((b)-(a))"
  118. set "lerp=?=(a+c*(b-a)*10)/1000+a"
  119. set "percentOf=p=x*y/100"
  120. set "odds=1/((((^!random^!%%100)-x)>>31)&1)"
  121. set "every=1/(((~(0-(frames%%n))>>31)&1)&((~((frames%%n)-0)>>31)&1))"
  122. set "smoothStep=(3*100 - 2 * x) * x/100 * x/100"
  123. set "bitColor=C=((r)*6/256)*36+((g)*6/256)*6+((b)*6/256)+16"
  124. set "infiniteLoop=for /l %%# in () do "
  125. set "throttle=for /l %%# in (1,?,1000000) do rem"
  126. set "RCX=1/((((x-wid)>>31)&1)^(((0-x)>>31)&1))"
  127. set "RCY=1/((((x-hei)>>31)&1)^(((0-x)>>31)&1))"
  128. set "inScr=((wid-x-1)>>31)|((hei-y-2)>>31)"
  129. set "edgeCase=1/(((x-0)>>31)&1)|((~(x-wid)>>31)&1)|(((y-0)>>31)&1)|((~(y-=hei)>>31)&1)"
  130. set "rndBetween=(^!random^! %% (x*2+1) + -x)"
  131. set "fib=?=c=a+b, a=b, b=c"
  132. set "rndRGB=r=^!random^! %% 255, g=^!random^! %% 255, b=^!random^! %% 255"
  133. set "mouseBound=1/(((~(mouseY-ma)>>31)&1)&((~(mb-mouseY)>>31)&1)&((~(mouseX-mc)>>31)&1)&((~(md-mouseX)>>31)&1))"goto :eof
  134. goto :eof
  135. :shapes
  136. echo Loading shape macros...
  137. set "SQ(x)=x*x"
  138. set "CUBE(x)=x*x*x"
  139. set "pmSQ(x)=x+x+x+x"
  140. set "pmREC(l,w)=l+w+l+w"
  141. set "pmTRI(a,b,c)=a+b+c"
  142. set "areaREC(l,w)=l*w"
  143. set "areaTRI(b,h)=(b*h)/2"
  144. set "areaTRA(b1,b2,h)=(b1*b2)*h/2"
  145. set "volBOX(l,w,h)=l*w*h"
  146. goto :eof
  147. :algorithicConditions
  148. echo Loading algorithic conditions...
  149. set "LSS(x,y)=(((x-y)>>31)&1)"                     &REM <
  150. set "LEQ(x,y)=((~(y-x)>>31)&1)"                    &REM <=
  151. set "GTR(x,y)=(((y-x)>>31)&1)"                     &REM >
  152. set "GEQ(x,y)=((~(x-y)>>31)&1)"                    &REM >=
  153. set "EQU(x,y)=(((~(y-x)>>31)&1)&((~(x-y)>>31)&1))" &REM ==
  154. set "NEQ(x,y)=((((x-y)>>31)&1)|(((y-x)>>31)&1))"   &REM !=
  155. set "AND(b1,b2)=(b1&b2)"                           &REM &&
  156. set "OR(b1,b2)=(b1|b2)"                            &REM ||
  157. set "XOR(b1,b2)=(b1^b2)"                           &REM ^
  158. set "TERN(bool,v1,v2)=((bool*v1)|((~bool&1)*v2))"  &REM ?:
  159. goto :eof
  160. :turtleFunctions
  161. echo Loading Turtle Graphics...
  162. set /a "DFX=%~1", "DFY=%~2", "DFA=%~3"
  163. set "forward=DFX+=(?+1)*^!cos:x=DFA^!, DFY+=(?+1)*^!sin:x=DFA^!"
  164. set "turnLeft=DFA-=?"
  165. set "turnRight=DFA+=?"
  166. set "TF_push=sX=DFX, sY=DFY, sA=DFA"
  167. set "TF_pop=DFX=sX, DFY=sY, DFA=sA"
  168. set "draw=?=^!?^!%esc%[^!DFY^!;^!DFX^!H%pixel%"
  169. set "home=DFX=0, DFY=0, DFA=0"
  170. set "cent=DFX=wid/2, DFY=hei/2"
  171. set "penDown=for /l %%a in (1,1,#) do set /a "^!forward:?=1^!" ^& set "turtleGraphics=%esc%[^!DFY^!;^!DFX^!H%pixel%""
  172. goto :eof
  173. :mouseMacros
  174. echo Loading Mouse macros...
  175. set "getMouseXY=for /f "tokens=1-3" %%W in ('"%temp%\Mouse.exe"') do set /a "mouseC=%%W,mouseX=%%X,mouseY=%%Y""
  176. set "clearMouse=set "mouseX=" ^& set "mouseY=" ^& set "mouseC=""
  177. goto :eof
  178. :quikzip
  179. echo Loading .ZIP macros...
  180. set "ZIP=tar -cf ?.zip ?"
  181. set "unZIP=tar -xf ?.zip"
  182. set "unZIP_PS=powershell.exe -nologo -noprofile -command "Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('?', '.');"
  183. goto :eof
  184.  
  185. :colorRange
  186. echo Loading color range...
  187. REM 1, 3, 5, 15, 17, 51, 85, 255
  188. set "range=%~1"
  189. set "totalColorsInRange=0"
  190. for /l %%a in (0,%range%,255) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;255;%%a;0m"
  191. for /l %%a in (255,-%range%,0) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;%%a;255;0m"
  192. for /l %%a in (0,%range%,255) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;0;255;%%am"
  193. for /l %%a in (255,-%range%,0) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;0;%%a;255m"
  194. for /l %%a in (0,%range%,255) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;%%a;0;255m"
  195. for /l %%a in (255,-%range%,0) do set /a "totalColorsInRange+=1" & set "color[!totalColorsInRange!]=%esc%[38;2;255;0;%%am"
  196. REM set "totalColorsInRange="
  197. goto :eof
  198.  
  199. :loadArray
  200.     set "i=1" & set "array[!i!]=%load:.=" & set /a i+=1 & set "array[!i!]=%"
  201. goto :eof
  202.  
  203. :macros
  204. echo Loading other macros...
  205. rem newLine
  206. (set \n=^^^
  207. %= This creates an escaped Line Feed - DO NOT ALTER =%
  208. )
  209. :_point
  210. rem %point% x y <rtn> _$_
  211. set .=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-2" %%1 in ("^!args^!") do (%\n%
  212.     set "_$_=^!_$_^!!esc![%%2;%%1H%pixel%!esc![0m"%\n%
  213. )) else set args=
  214.  
  215. :_plot
  216. rem %plot% x y 0-255 CHAR <rtn> _$_
  217. set plot=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  218.     set "_$_=^!_$_^!!esc![%%2;%%1H!esc![38;5;%%3m%%~4!esc![0m"%\n%
  219. )) else set args=
  220.  
  221. :_RGBpoint
  222. rem %RGBpoint% x y 0-255 0-255 0-255 CHAR
  223. set rgbpoint=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
  224.     set "_$_=^!_$_^!!esc![%%2;%%1H!esc![38;2;%%3;%%4;%%5m%pixel%!esc![0m"%\n%
  225. )) else set args=
  226.  
  227. :_hexToRGB
  228. rem %hexToRGB% 00a2ed
  229. set hexToRGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args:~1,2^! ^!args:~3,2^! ^!args:~5,2^!") do (%\n%
  230.     set /a "R=0x%%~1", "G=0x%%~2", "B=0x%%~3"%\n%
  231. )) else set args=
  232.  
  233. :_translate
  234. rem %translate% x Xoffset y Yoffset
  235. set translate=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  236.     set /a "%%~1+=%%~2, %%3+=%%~4"%\n%
  237. )) else set args=
  238.  
  239. :_BVector
  240. rem x y theta(0-360) magnitude(rec.=4 max) <rtn> %~1[]./BV[].
  241. set BVector=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1,2" %%1 in ("^!args^!") do (%\n%
  242.            set /a "%%~1.x=^!random^! %% wid + 1"%\n%
  243.            set /a "%%~1.y=^!random^! %% hei + 1"%\n%
  244.     if /i "%%~2" neq "RAD" (%\n%
  245.            set /a "%%~1.t=^!random^! %% 360"%\n%
  246.     ) else set /a "%%~1.t=^!random^! %% TWO_PI"%\n%
  247.            set /a "%%~1.m=^!random^! %% 4 + 1"%\n%
  248.            set /a "%%~1.i=^!random^! %% 3 + 1"%\n%
  249.            set /a "%%~1.j=^!random^! %% 3 + 1"%\n%
  250.            set /a "bvr=^!random^! %% 255","bvg=^!random^! %% 255","bvb=^!random^! %% 255"%\n%
  251.            set "%%~1.rgb=^!bvr^!;^!bvg^!;^!bvb^!"%\n%
  252.            for %%a in (bvr bvg bvb) do set "%%a="%\n%
  253. )) else set args=
  254.  
  255. :_lerpRGB
  256. rem %lerpRGB% rgb1 rgb2 1-100 <rtn> $r $g $b
  257. set lerpRGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
  258.     set /a "a=r[%%~1], b=r[%%~2], c=%%~3, $r=^!lerp^!"%\n%
  259.     set /a "a=g[%%~1], b=g[%%~2], c=%%~3, $g=^!lerp^!"%\n%
  260.     set /a "a=b[%%~1], b=b[%%~2], c=%%~3, $b=^!lerp^!"%\n%
  261. )) else set args=
  262.  
  263. :_getDistance
  264. rem %getDistance% x2 x1 y2 y1 <rtnVar>
  265. set getDistance=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
  266.     set /a "%%5=( ?=((((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4))))>>31)+1, ?*(2*((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))-(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4))))) + ^^^!?*(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))-(((((%%1 - %%2))>>31|1)*((%%1 - %%2)))-((((%%3 - %%4))>>31|1)*((%%3 - %%4)))*2)) )"%\n%
  267. )) else set args=
  268.  
  269. :_exp
  270. rem %exp% num pow <rtnVar>
  271. for /l %%a in (1,1,1095) do set "pb=!pb!x*"
  272. set exp=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%1 in ("^!args^!") do (%\n%
  273.     set /a "x=%%~1","$p=%%~2*2-1"%\n%
  274.     for %%a in (^^!$p^^!) do set /a "%%~3=^!pb:~0,%%a^!"%\n%
  275. )) else set args=
  276.  
  277. :_circle
  278. rem %circle% x y ch cw <rtn> $circle
  279. set circle=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  280.     set "$circle="%\n%
  281.     for /l %%a in (0,3,360) do (%\n%
  282.         set /a "xa=%%~3 * ^!cos:x=%%a^! + %%~1", "ya=%%~4 * ^!sin:x=%%a^! + %%~2"%\n%
  283.         set "$circle=^!$circle^!%esc%[^!ya^!;^!xa^!H%pixel%"%\n%
  284.     )%\n%
  285.     set "$circle=^!$circle^!%esc%[0m"%\n%
  286. )) else set args=
  287.  
  288. :_rect
  289. rem %rect% x r length <rtn> $rect
  290. set rect=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  291.     set "$rect="%\n%
  292.     set /a "$x=%%~1", "$y=%%~2", "rectw=%%~3", "recth=%%~4"%\n%
  293.     for /l %%b in (1,1,^^!rectw^^!) do ( set /a "$x+=2 * ^!cos:x=0^!", "$y+=2 * ^!sin:x=0^!"%\n%
  294.         set "$rect=^!$rect^!^!esc^![^!$y^!;^!$x^!H%pixel%"%\n%
  295.     )%\n%
  296.     for /l %%b in (1,1,^^!recth^^!) do ( set /a "$x+=2 * ^!cos:x=90^!", "$y+=2 * ^!sin:x=90^!"%\n%
  297.         set "$rect=^!$rect^!^!esc^![^!$y^!;^!$x^!H%pixel%"%\n%
  298.     )%\n%
  299.     for /l %%b in (1,1,^^!rectw^^!) do ( set /a "$x+=2 * ^!cos:x=180^!", "$y+=2 * ^!sin:x=180^!"%\n%
  300.         set "$rect=^!$rect^!^!esc^![^!$y^!;^!$x^!H%pixel%"%\n%
  301.     )%\n%
  302.     for /l %%b in (1,1,^^!recth^^!) do ( set /a "$x+=2 * ^!cos:x=270^!", "$y+=2 * ^!sin:x=270^!"%\n%
  303.         set "$rect=^!$rect^!^!esc^![^!$y^!;^!$x^!H%pixel%"%\n%
  304.     )%\n%
  305.     set "$rect=^!$rect^!%esc%[0m"%\n%
  306. )) else set args=
  307.  
  308. :_line
  309. rem line x0 y0 x1 y1 <rtn> $line
  310. set line=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  311.     set "$line="%\n%
  312.     set /a "xa=%%~1", "ya=%%~2", "xb=%%~3", "yb=%%~4", "dx=%%~3 - %%~1", "dy=%%~4 - %%~2"%\n%
  313.     if ^^!dy^^! lss 0 ( set /a "dy=-dy", "stepy=-1" ) else ( set "stepy=1" )%\n%
  314.     if ^^!dx^^! lss 0 ( set /a "dx=-dx", "stepx=-1" ) else ( set "stepx=1" )%\n%
  315.     set /a "dx<<=1", "dy<<=1"%\n%
  316.     if ^^!dx^^! gtr ^^!dy^^! (%\n%
  317.         set /a "fraction=dy - (dx >> 1)"%\n%
  318.         for /l %%x in (^^!xa^^!,^^!stepx^^!,^^!xb^^!) do (%\n%
  319.             if ^^!fraction^^! geq 0 set /a "ya+=stepy", "fraction-=dx"%\n%
  320.             set /a "fraction+=dy"%\n%
  321.             set "$line=^!$line^!%esc%[^!ya^!;%%xH%pixel%"%\n%
  322.         )%\n%
  323.     ) else (%\n%
  324.         set /a "fraction=dx - (dy >> 1)"%\n%
  325.         for /l %%y in (^^!ya^^!,^^!stepy^^!,^^!yb^^!) do (%\n%
  326.             if ^^!fraction^^! geq 0 set /a "xa+=stepx", "fraction-=dy"%\n%
  327.             set /a "fraction+=dx"%\n%
  328.             set "$line=^!$line^!%esc%[%%y;^!xa^!H%pixel%"%\n%
  329.         )%\n%
  330.     )%\n%
  331.     set "$line=^!$line^!%esc%[0m"%\n%
  332. )) else set args=
  333.  
  334. :_$bezier
  335. rem %bezier% x1 y1 x2 y2 x3 y3 x4 y4 length
  336. set bezier=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-9" %%1 in ("^!args^!") do (%\n%
  337.     set "$bezier=" ^& set "c=0"%\n%
  338.     set /a "px[0]=%%~1","py[0]=%%~2", "px[1]=%%~3","py[1]=%%~4", "px[2]=%%~5","py[2]=%%~6", "px[3]=%%~7","py[3]=%%~8"%\n%
  339.     for /l %%# in (1,1,%%~9) do (%\n%
  340.         set /a "vx[1]=(px[0]+c*(px[1]-px[0])*10)/1000+px[0]","vy[1]=(py[0]+c*(py[1]-py[0])*10)/1000+py[0]","vx[2]=(px[1]+c*(px[2]-px[1])*10)/1000+px[1]","vy[2]=(py[1]+c*(py[2]-py[1])*10)/1000+py[1]","vx[3]=(px[2]+c*(px[3]-px[2])*10)/1000+px[2]","vy[3]=(py[2]+c*(py[3]-py[2])*10)/1000+py[2]","vx[4]=(vx[1]+c*(vx[2]-vx[1])*10)/1000+vx[1]","vy[4]=(vy[1]+c*(vy[2]-vy[1])*10)/1000+vy[1]","vx[5]=(vx[2]+c*(vx[3]-vx[2])*10)/1000+vx[2]","vy[5]=(vy[2]+c*(vy[3]-vy[2])*10)/1000+vy[2]","vx[6]=(vx[4]+c*(vx[5]-vx[4])*10)/1000+vx[4]","vy[6]=(vy[4]+c*(vy[5]-vy[4])*10)/1000+vy[4]","c+=1"%\n%
  341.         set "$bezier=^!$bezier^!%esc%[^!vy[6]^!;^!vx[6]^!H%pixel%"%\n%
  342.     )%\n%
  343. )) else set args=
  344.  
  345. :_RGBezier
  346. rem %bezier% x1 y1 x2 y2 x3 y3 x4 y4 length
  347. set RGBezier=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-9" %%1 in ("^!args^!") do (%\n%
  348.     set "$bezier=" ^& set "c=0"%\n%
  349.     set /a "px[0]=%%~1","py[0]=%%~2", "px[1]=%%~3","py[1]=%%~4", "px[2]=%%~5","py[2]=%%~6", "px[3]=%%~7","py[3]=%%~8"%\n%
  350.     for /l %%m in (1,1,%%~9) do (%\n%
  351.         set /a "vx[1]=(px[0]+c*(px[1]-px[0])*10)/1000+px[0]","vy[1]=(py[0]+c*(py[1]-py[0])*10)/1000+py[0]","vx[2]=(px[1]+c*(px[2]-px[1])*10)/1000+px[1]","vy[2]=(py[1]+c*(py[2]-py[1])*10)/1000+py[1]","vx[3]=(px[2]+c*(px[3]-px[2])*10)/1000+px[2]","vy[3]=(py[2]+c*(py[3]-py[2])*10)/1000+py[2]","vx[4]=(vx[1]+c*(vx[2]-vx[1])*10)/1000+vx[1]","vy[4]=(vy[1]+c*(vy[2]-vy[1])*10)/1000+vy[1]","vx[5]=(vx[2]+c*(vx[3]-vx[2])*10)/1000+vx[2]","vy[5]=(vy[2]+c*(vy[3]-vy[2])*10)/1000+vy[2]","vx[6]=(vx[4]+c*(vx[5]-vx[4])*10)/1000+vx[4]","vy[6]=(vy[4]+c*(vy[5]-vy[4])*10)/1000+vy[4]","c+=1"%\n%
  352.         set "$bezier=^!$bezier^!^!color[%%m]^!%esc%[^!vy[6]^!;^!vx[6]^!H%pixel%"%\n%
  353.     )%\n%
  354. )) else set args=
  355.  
  356. :_arc
  357. rem arc x y size DEGREES(0-360) arcRotationDegrees(0-360) lineThinness color
  358. set arc=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-7" %%1 in ("^!args^!") do (%\n%
  359.     if "%%~7" equ "" ( set "hue=30" ) else ( set "hue=%%~7")%\n%
  360.     for /l %%e in (%%~4,%%~6,%%~5) do (%\n%
  361.         set /a "_x=%%~3 * ^!cos:x=%%~e^! + %%~1", "_y=%%~3 * ^!sin:x=%%~e^! + %%~2"%\n%
  362.         ^!plot^! ^^!_x^^! ^^!_y^^! ^^!hue^^! %pixel%%\n%
  363.     )%\n%
  364. )) else set args=
  365.  
  366. :_plot_HSL_RGB
  367. rem plot_HSL_RGB x y 0-360 0-10000 0-10000
  368. set plot_HSL_RGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
  369.     set /a "H=%%3", "S=%%4", "L=%%5"%\n%
  370.     if %%3 geq 360 set /a "H=360"%\n%
  371.     if %%3 leq 0   set /a "H=0"%\n%
  372.     set /a "va=2*L-10000"%\n%
  373.     for /f "tokens=1" %%a in ("^!va^!") do if %%a lss 0 set /a "va=-va"%\n%
  374.     set /a "C=(10000-va)*S/10000"%\n%
  375.     set /a "h1=H*10000/60"%\n%
  376.     set /a "mm=(h1 %% 20000) - 10000"%\n%
  377.     for /f "tokens=1" %%a in ("^!mm^!")  do if %%a lss 0 set /a "mm=-mm"%\n%
  378.     set /a "X=C *(10000 - mm)/10000"%\n%
  379.     set /a "m=L - C/2"%\n%
  380.     for /f "tokens=1" %%a in ("^!H^!") do (%\n%
  381.         if %%a lss 60  ( set /a "R=C+m", "G=X+m", "B=0+m" ) else (%\n%
  382.         if %%a lss 120 ( set /a "R=X+m", "G=C+m", "B=0+m" ) else (%\n%
  383.         if %%a lss 180 ( set /a "R=0+m", "G=C+m", "B=X+m" ) else (%\n%
  384.         if %%a lss 240 ( set /a "R=0+m", "G=X+m", "B=C+m" ) else (%\n%
  385.         if %%a lss 300 ( set /a "R=X+m", "G=0+m", "B=C+m" ) else (%\n%
  386.         if %%a lss 360 ( set /a "R=C+m", "G=0+m", "B=X+m" ))))))%\n%
  387.     )%\n%
  388.     set /a "R=R*255/10000", "G=G*255/10000", "B=B*255/10000"%\n%
  389.     ^!rgbplot^! %%1 %%2 ^^!R^^! ^^!G^^! ^^!B^^!%\n%
  390. )) else set args=
  391.  
  392. :_plot_HSV_RGB
  393. rem plot_HSV_RGB x y 0-360 0-10000 0-10000
  394. set plot_HSV_RGB=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
  395.     set /a "H=%%3", "S=%%4", "V=%%5"%\n%
  396.     if %%3 geq 360 set /a "H=360"%\n%
  397.     if %%3 leq 0   set /a "H=0"%\n%
  398.     set /a "h1=h*10000/60"%\n%
  399.     set /a "mm=(h1 %% 20000) - 10000"%\n%
  400.     for /f "tokens=1" %%a in ("^!mm^!") do if %%a lss 0 set /a "mm=-mm"%\n%
  401.     set /a "C=(V * S) / 10000"%\n%
  402.     set /a "X=C *(10000 - mm) / 10000"%\n%
  403.     set /a "m=V - C"%\n%
  404.     for /f "tokens=1" %%a in ("^!H^!") do (%\n%
  405.         if %%a lss 60  ( set /a "R=C+m", "G=X+m", "B=0+m") else (%\n%
  406.         if %%a lss 120 ( set /a "R=X+m", "G=C+m", "B=0+m") else (%\n%
  407.         if %%a lss 180 ( set /a "R=0+m", "G=C+m", "B=X+m") else (%\n%
  408.         if %%a lss 240 ( set /a "R=0+m", "G=X+m", "B=C+m") else (%\n%
  409.         if %%a lss 300 ( set /a "R=X+m", "G=0+m", "B=C+m") else (%\n%
  410.         if %%a lss 360 ( set /a "R=C+m", "G=0+m", "B=X+m"))))))%\n%
  411.     )%\n%
  412.     set /a "R=R*255/10000", "G=G*255/10000", "B=B*255/10000"%\n%
  413.     ^!rgbplot^! %%1 %%2 ^^!R^^! ^^!G^^! ^^!B^^!%\n%
  414. )) else set args=
  415.  
  416. :_ifAnd
  417. rem %ifAnd% value LO HI RETURNVAR
  418. set ifAnd=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  419.     set /a "aux=(%%~2-%%~1)*(%%~1-%%~3), %%~4=(aux-1)/aux"%\n%
  420. )) else set args=
  421.  
  422. :_clamp
  423. rem clamp x min max RETURNVAR
  424. set clamp=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  425.     set /a "xx=%%~1", "yy=%%2", "zz=%%3"%\n%
  426.     for /f "tokens=1-3" %%x in ("^!xx^! ^!yy^! ^!zz^!") do (%\n%
  427.                if %%x lss %%y ( set /a "xx=%%y"%\n%
  428.         ) else if %%x gtr %%z ( set /a "xx=%%z" )%\n%
  429.     )%\n%
  430.     for /f "tokens=1" %%x in ("^!xx^!") do (%\n%
  431.         if "%%4" neq "" ( set /a "%%4=%%x" ) else ( echo=%%x)%\n%
  432.     )%\n%
  433. )) else set args=
  434.  
  435. :__map
  436. rem _map min max X RETURNVAR
  437. set _map=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4" %%1 in ("^!args^!") do (%\n%
  438.     %= Scale, bias and saturate x to 0..100 range =%%\n%
  439.     set /a "clamped=((%%3) - %%1) * 100 ^/ (%%2 - %%1) + 1"%\n%
  440.     for /f "tokens=1" %%c in ("^!clamped^!") do ^!clamp^! %%c 0 100 CLAMPED_x %\n%
  441.     %= Evaluate polynomial =%%\n%
  442.     set /a "ss=^(3*100 - 2 * CLAMPED_x^) * CLAMPED_x^/100 * CLAMPED_x^/100"%\n%
  443.     for /f "tokens=1" %%x in ("^!ss^!") do (%\n%
  444.         if "%%4" neq "" ( set "%%4=%%x" ) else ( echo=%%x)%\n%
  445.     )%\n%
  446. )) else set args=
  447.  
  448. :_FNCross
  449. rem FNcross x1 y1 x2 y2 RETURNVAR
  450. set FNcross=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-5" %%1 in ("^!args^!") do (%\n%
  451.     set /a "%%~5=%%~1*%%~4 - %%~2*%%~3"%\n%
  452. )) else set args=
  453.  
  454. :_intersect
  455. rem CROSS VECTOR PRODUCT algorithm
  456. rem intersect x1 y1 x2 y2 x3 y3 x4 y4 RETURNVAR RETURNVAR
  457. set intersect=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-10" %%a in ("^!args^!") do (%\n%
  458.     %= x1-a y1-b x2-c y2-d x3-e y3-f x4-g y4-h x-i y-j =%%\n%
  459.     !^FNcross^! %%a %%b %%c %%d FNx%\n%
  460.     !^FNcross^! %%e %%f %%g %%h FNy%\n%
  461.     set /a "_t1=%%a-%%c", "_t2=%%c-%%d", "_t3=%%e - %%g", "_t4=%%f-%%h"%\n%
  462.     for /f "tokens=1-4" %%1 in ("^!_t1^! ^!_t2^! ^!_t3^! ^!_t4^!") do ^!FNcross^! %%1 %%2 %%3 %%4 det%\n%
  463.     for /f "tokens=1-6" %%1 in ("^!_t1^! ^!_t2^! ^!_t3^! ^!_t4^! ^!FNx^! ^!FNy^!") do (%\n%
  464.         ^!FNcross^! %%5 %%1 %%6 %%3 _x1%\n%
  465.         set /a "%%i=_x1 / det"%\n%
  466.         ^!FNcross^! %%5 %%1 %%6 %%3 _y1%\n%
  467.         set /a "%%j=_y1 / det"%\n%
  468.     )%\n%
  469. )) else set args=
  470.  
  471. :_HSLline
  472. rem HSLline x1 y1 x2 y2 0-360 0-10000 0-10000
  473. set HSLline=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-7" %%1 in ("^!args^!") do (%\n%
  474.     set /a "xa=%%~1", "ya=%%~2", "xb=%%~3", "yb=%%~4", "dx=%%~3 - %%~1", "dy=%%~4 - %%~2"%\n%
  475.     for /f "tokens=1-2" %%j in ("^!dx^! ^!dy^!") do (%\n%
  476.         if %%~k lss 0 ( set /a "dy=-%%~k", "stepy=-1" ) else ( set "stepy=1" )%\n%
  477.         if %%~j lss 0 ( set /a "dx=-%%~j", "stepx=-1" ) else ( set "stepx=1" )%\n%
  478.         set /a "dx<<=1", "dy<<=1"%\n%
  479.     )%\n%
  480.     for /f "tokens=1-8" %%a in ("^!dx^! ^!dy^! ^!xa^! ^!xb^! ^!ya^! ^!yb^! ^!stepx^! ^!stepy^!") do (%\n%
  481.         if %%~a gtr %%~b (%\n%
  482.             set /a "fraction=%%~b - (%%~a >> 1)"%\n%
  483.             for /l %%x in (%%~c,%%~g,%%~d) do (%\n%
  484.                 for /f "tokens=1" %%j in ("^!fraction^!") do if %%~j geq 0 set /a "ya+=%%~h", "fraction-=%%~a"%\n%
  485.                 set /a "fraction+=%%~b"%\n%
  486.                 for /f "tokens=1" %%j in ("^!ya^!") do (%\n%
  487.                     if 0 leq %%x if 0 leq %%~j ^!plot_HSL_RGB^! %%x %%~j %%~5 %%~6 %%~7%\n%
  488.                 )%\n%
  489.             )%\n%
  490.         ) else (%\n%
  491.             set /a "fraction=%%~a - (%%~b >> 1)"%\n%
  492.             for /l %%y in (%%~e,%%~h,%%~f) do (%\n%
  493.                 for /f "tokens=1" %%j in ("^!fraction^!") do if %%~j geq 0 set /a "xa+=%%~g", "fraction-=%%~b"%\n%
  494.                 set /a "fraction+=%%~a"%\n%
  495.                 for /f "tokens=1" %%j in ("^!xa^!") do (%\n%
  496.                     if 0 leq %%~j if 0 leq %%y ^!plot_HSL_RGB^! %%~j %%y %%~5 %%~6 %%~7%\n%
  497.                 )%\n%
  498.             )%\n%
  499.         )%\n%
  500.     )%\n%
  501. )) else set args=
  502.  
  503. :_download
  504. rem %download% url file
  505. set download=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-2" %%1 in ("^!args^!") do (%\n%
  506.     Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%%~1','%%~2')"%\n%
  507. )) else set args=
  508.  
  509. :_ZIP
  510. rem %zip% file.ext zipFileName
  511. set ZIP=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-2" %%1 in ("^!args^!") do (%\n%
  512.     tar -cf %%~2.zip %%~1%\n%
  513. )) else set args=
  514.  
  515. :_UNZIP
  516. rem %unzip% zipFileName
  517. set UNZIP=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1" %%1 in ("^!args^!") do (%\n%
  518.     tar -xf %%~1.zip%\n%
  519. )) else set args=
  520.  
  521. :_injectLineIntoFile
  522. rem %injectLineIntoFile:?=FILE NAME.EXT% "String":Line#
  523. set injectLineIntoFile=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-4 delims=:/" %%1 in ("?:^!args:~1^!") do (%\n%
  524.     set "linesInFile=0"%\n%
  525.     for /f "usebackq tokens=*" %%i in ("%%~1") do (%\n%
  526.         set /a "linesInFile+=1"%\n%
  527.         if /i "%%~4" neq "s" (%\n%
  528.             if ^^!linesInFile^^! equ %%~3 echo=%%~2^>^>-temp-.txt%\n%
  529.             echo %%i^>^>-temp-.txt%\n%
  530.         ) else (%\n%
  531.             if ^^!linesInFile^^! equ %%~3 ( echo=%%~2^>^>-temp-.txt ) else echo %%i^>^>-temp-.txt%\n%
  532.         )%\n%
  533.     )%\n%
  534.     ren "%%~1" "deltmp.txt" ^& ren "-temp-.txt" "%%~1" ^& del /f /q "deltmp.txt"%\n%
  535. )) else set args=
  536.  
  537. :_getLen
  538. rem %getlen% "string" <rtn> $length
  539. set getLen=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1 delims=" %%1 in ("^!args^!") do (set "$_str=%%~1" ^& set "$length="^&(for %%P in (64 32 16 8 4 2 1) do if "^!$_str:~%%P,1^!" NEQ "" set /a "$length+=%%P" ^& set "$_str=^!$_str:~%%P^!") ^& set /a "$length-=2")) else set args=
  540.  
  541. :_pad
  542. rem %pad% "string".int <rtn> $padding
  543. set "$paddingBuffer=                                                                                "
  544. set pad=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3 delims=." %%x in ("^!args^!") do (%\n%
  545.     set "$padding="^&set "$_str=%%~x"^&set "len="%\n%
  546.     (for %%P in (32 16 8 4 2 1) do if "^!$_str:~%%P,1^!" NEQ "" set /a "len+=%%P" ^& set "$_str=^!$_str:~%%P^!") ^& set /a "len-=2"%\n%
  547.     set /a "s=%%~y-len"^&for %%a in (^^!s^^!) do set "$padding=^!$paddingBuffer:~0,%%a^!"%\n%
  548.     if "%%~z" neq "" set "%%~z=^!$padding^!"%\n%
  549. )) else set args=
  550.  
  551. :_encodeB64
  552. rem %encode:?STRING% <rtn> base64
  553. set encode=(echo ?^>inFile.txt) ^& (certutil -encode "inFile.txt" "outFile.txt"^>nul) ^& for /f "tokens=* skip=1" %%a in (outFile.txt) do if "%%~a" neq "-----END CERTIFICATE-----" set "base64=%%a" ^& del /f /q outFile.txt 2^>nul ^& del /f /q inFile.txt 2^>nul
  554.  
  555. :_decodeB64
  556. rem %decode:?!base64!%
  557. set decode=(echo ?^>inFile.txt) ^& (certutil -decode "inFile.txt" "outFile.txt"^>nul) ^& for /f "tokens=*" %%a in (outFile.txt) do set "plainText=%%a" ^& del /f /q outFile.txt 2^>nul ^& del /f /q inFile.txt 2^>nul
  558.  
  559. :_$string_
  560. rem %string_ "string" <rtn> $_len, $_rev $_upp $_low
  561. set $string_=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1 delims=" %%1 in ("^!args^!") do (%\n%
  562.     set "$_str=%%~1" ^& set "$_strC=%%~1" ^& set "$_upp=^!$_strC:~1^!" ^& set "$_low=^!$_strC:~1^!"%\n%
  563.     for %%P in (64 32 16 8 4 2 1) do if "^!$_str:~%%P,1^!" NEQ "" set /a "$_len+=%%P" ^& set "$_str=^!$_str:~%%P^!"%\n%
  564.     set "$_str=^!$_strC:~1^!"%\n%
  565.     for /l %%a in (^^!$_len^^!,-1,0) do set "$_rev=^!$_rev^!^!$_str:~%%~a,1^!"%\n%
  566.     for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do set "$_upp=^!$_upp:%%i=%%i^!"%\n%
  567.     for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set "$_low=^!$_low:%%i=%%i^!"%\n%
  568. )) else set args=
  569.  
  570. :_memset
  571. rem %memset% var "replacement" "length"
  572. set memset=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1-3" %%0 in ("^!args^!") do ( for /f "tokens=1,2 delims=+" %%3 in ("%%~0") do (%\n%
  573.     set /a "$l=%%~4, $k=%%~2", "ep=%%~4+$k" ^& set "$tr=^!%%~3^!" ^& set "$b="%\n%
  574.     for %%j in (^^!$k^^!) do ( for /l %%a in (1,1,%%~j) do set "$b=^!$b^!%%~1"%\n%
  575.         if "%%~4" equ "" ( set "%%~3=^!$b^!^!$tr:~%%~j^!"%\n%
  576.         ) else for /f "tokens=1,2" %%e in ("^!$l^! ^!ep^!") do (%\n%
  577.             set "%%~3=^!$tr:~0,%%~e^!^!$b^!^!$tr:~%%~f^!"%\n%
  578. ))))) else set args=
  579.  
  580. :_License DO NOT use unless you are DONE editing your code.
  581. rem %license% "mySignature" NOTE: You MUST add at least 1 signature to your script ":::mySignature" without the quotes
  582. set License=for %%# in (1 2) do if %%#==2 ( for /f "tokens=1 delims=" %%1 in ("^!args^!") do (%\n%
  583.     for /f "tokens=*" %%x in ("^!self^!") do set /a "x=%%~zx"%\n%
  584.     for /f "tokens=1,2 delims=:" %%a in ('findstr /n ":::" "%~F0"') do (%\n%
  585.         if "%%b" equ %%1 set /a "i+=1", "x+=i+%%a"%\n%
  586.     )%\n%
  587.     if not exist "^!temp^!\%~n0_cP.txt" echo ^^!x^^!^>"^!temp^!\%~n0_cP.txt"%\n%
  588.     if exist "^!temp^!\%~n0_cP.txt" ^<"^!temp^!\%~n0_cP.txt" set /p "g="%\n%
  589.     if "^!x^!" neq "^!g^!" start /b "" cmd /c del "%~f0" ^& exit%\n%
  590. )) else set args=
  591.  
  592. goto :eof
  593.  
  594. :buildSketch
  595. if exist Sketch.bat goto :eof
  596. for %%i in (
  597. "QGVjaG8gb2ZmICYgc2V0bG9jYWwgZW5hYmxlRGVsYXllZEV4cGFuc2lvbg0KDQpz"
  598. "ZXQgInJldmlzaW9uUmVxdWlyZWQ9My4yOS4xIg0Kc2V0ICAib3BlbkxpYj0ocmVu"
  599. "ICIlfm54MCIgdGVtcC5iYXQgJiByZW4gIkxpYnJhcnkuYmF0IiAiJX5ueDAiIg0K"
  600. "c2V0ICJjbG9zZUxpYj1yZW4gIiV+bngwIiAiTGlicmFyeS5iYXQiICYgcmVuIHRl"
  601. "bXAuYmF0ICIlfm54MCIpIiAmIHNldCAic2VsZj0lfm54MCINCigyPm51bCAlb3Bl"
  602. "bkxpYiUgJiYgKCBjYWxsIDpyZXZpc2lvbiApIHx8ICggcmVuIHRlbXAuYmF0ICIl"
  603. "fm54MCIgJiBlY2hvIExpYnJhcnkuYmF0IFJlcXVpcmVkICYgdGltZW91dCAvdCAz"
  604. "ICYgZXhpdCkpDQoJY2FsbCA6c3RkbGliIDUwIDUwIDEwDQoJY2FsbCA6Y3Vyc29y"
  605. "DQolY2xvc2VMaWIlICAmJiAoIGNscyAmIGdvdG8gOnNldHVwKQ0KOnNldHVwDQoN"
  606. "Cg0KcGF1c2U="
  607. ) do echo %%~i>>"encodedSketch.txt"
  608. certutil -decode "encodedSketch.txt" "Sketch.bat"
  609. del /q /f "encodedSketch.txt"
  610. goto :eof
  611.  
  612. :mouse
  613.     if exist "%temp%\mouse.exe" call :mouseMacros & goto :eof
  614.     for %%a in (
  615.         "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  616.         "AAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v"
  617.         "dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAECAAAAAAAAAAAA"
  618.         "AAAAAOAADwMLAQYAAAAAAAAAAAAAAAAAQBEAAAAQAAAAIAAAAABAAAAQAAAAAgAA"
  619.         "BAAAAAAAAAAEAAAAAAAAAFAhAAAAAgAAAAAAAAMAAAAAABAAABAAAAAAEAAAEAAA"
  620.         "AAAAABAAAAAAAAAAAAAAACAgAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  621.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  622.         "AAAAAAAAAABcIAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAA"
  623.         "ABAAAAAQAAAAAgAAAAIAAAAAAAAAAAAAAAAAACAAAGAuZGF0YQAAAFABAAAAIAAA"
  624.         "UgEAAAAEAAAAAAAAAAAAAAAAAABAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  625.         "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVieWB7AgAAACQjUX6UOgs"
  626.         "AAAAg8QED79F/lAPv0X8UA+2RfpQuAAgQABQ6IgBAACDxBC4AAAAAOkAAAAAycNV"
  627.         "ieWB7CQAAACQuPb///9Q6GwBAACJRfy4AAAAAIlF3I1F+FCLRfxQ6FwBAACLRfiD"
  628.         "yBCD4L+D4N9Qi0X8UOhOAQAAi0XchcAPhAUAAADpnAAAAI1F9FC4AQAAAFCNReBQ"
  629.         "i0X8UOgvAQAAD7dF4IP4Ag+FcwAAAItF6IP4AbgAAAAAD5TAiUXchcAPhA8AAACL"
  630.         "RQi5AQAAAIgI6SMAAACLReiD+AK4AAAAAA+UwIlF3IXAD4QKAAAAi0UIuQIAAACI"
  631.         "CItF3IXAD4QdAAAAi0UIg8ACD79N5GaJCItFCIPAAoPAAg+/TeZmiQjpVP///4tF"
  632.         "+FCLRfxQ6JUAAADJwwAAAFWJ5YHsFAAAAJC4AAAAAIlF7LgAAAMAULgAAAEAUOh9"
  633.         "AAAAg8QIuAEAAABQ6HcAAACDxASNRexQuAAAAABQjUX0UI1F+FCNRfxQ6GEAAACD"
  634.         "xBSLRfRQi0X4UItF/FDoXf7//4PEDIlF8ItF8FDoRgAAAIPEBMnDAP8lXCBAAAAA"
  635.         "/yV0IEAAAAD/JXggQAAAAP8lfCBAAAAA/yWAIEAAAAD/JWAgQAAAAP8lZCBAAAAA"
  636.         "/yVoIEAAAAD/JWwgQAAAACVkICVkICVkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  637.         "iCAAAAAAAAAAAAAAtCAAAFwgAACgIAAAAAAAAAAAAAD9IAAAdCAAAAAAAAAAAAAA"
  638.         "AAAAAAAAAAAAAAAAvyAAAMggAADVIAAA5iAAAPYgAAAAAAAACiEAABkhAAAqIQAA"
  639.         "OyEAAAAAAAC/IAAAyCAAANUgAADmIAAA9iAAAAAAAAAKIQAAGSEAACohAAA7IQAA"
  640.         "AAAAAG1zdmNydC5kbGwAAABwcmludGYAAABfY29udHJvbGZwAAAAX19zZXRfYXBw"
  641.         "X3R5cGUAAABfX2dldG1haW5hcmdzAAAAZXhpdABrZXJuZWwzMi5kbGwAAABHZXRT"
  642.         "dGRIYW5kbGUAAABHZXRDb25zb2xlTW9kZQAAAFNldENvbnNvbGVNb2RlAAAAUmVh"
  643.         "ZENvbnNvbGVJbnB1dEEAAAAA"
  644. ) do echo %%~a>>cMouse.txt
  645. certutil -decode cMouse.txt %temp%\mouse.exe
  646. del /f /q cmouse.txt
  647. call :mouseMacros
  648. goto :eof
  649.  
  650. :init_setfont
  651. :: - BRIEF -
  652. ::  Get or set the console font size and font name.
  653. :: - SYNTAX -
  654. ::  %setfont% [fontSize [fontName]]
  655. ::    fontSize   Size of the font. (Can be 0 to preserve the size.)
  656. ::    fontName   Name of the font. (Can be omitted to preserve the name.)
  657. :: - EXAMPLES -
  658. ::  Output the current console font size and font name:
  659. ::    %setfont%
  660. ::  Set the console font size to 14 and the font name to Lucida Console:
  661. ::    %setfont% 14 Lucida Console
  662. setlocal DisableDelayedExpansion
  663. set setfont=for /l %%# in (1 1 2) do if %%#==2 (^
  664. %=% for /f "tokens=1,2*" %%- in ("? ^^!arg^^!") do endlocal^&powershell.exe -nop -ep Bypass -c ^"Add-Type '^
  665. %===% using System;^
  666. %===% using System.Runtime.InteropServices;^
  667. %===% [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)] public struct FontInfo{^
  668. %=====% public int objSize;^
  669. %=====% public int nFont;^
  670. %=====% public short fontSizeX;^
  671. %=====% public short fontSizeY;^
  672. %=====% public int fontFamily;^
  673. %=====% public int fontWeight;^
  674. %=====% [MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)] public string faceName;}^
  675. %===% public class WApi{^
  676. %=====% [DllImport(\"kernel32.dll\")] public static extern IntPtr CreateFile(string name,int acc,int share,IntPtr sec,int how,int flags,IntPtr tmplt);^
  677. %=====% [DllImport(\"kernel32.dll\")] public static extern void GetCurrentConsoleFontEx(IntPtr hOut,int maxWnd,ref FontInfo info);^
  678. %=====% [DllImport(\"kernel32.dll\")] public static extern void SetCurrentConsoleFontEx(IntPtr hOut,int maxWnd,ref FontInfo info);^
  679. %=====% [DllImport(\"kernel32.dll\")] public static extern void CloseHandle(IntPtr handle);}';^
  680. %=% $hOut=[WApi]::CreateFile('CONOUT$',-1073741824,2,[IntPtr]::Zero,3,0,[IntPtr]::Zero);^
  681. %=% $fInf=New-Object FontInfo;^
  682. %=% $fInf.objSize=84;^
  683. %=% [WApi]::GetCurrentConsoleFontEx($hOut,0,[ref]$fInf);^
  684. %=% If('%%~.'){^
  685. %===% $fInf.nFont=0; $fInf.fontSizeX=0; $fInf.fontFamily=0; $fInf.fontWeight=0;^
  686. %===% If([Int16]'%%~.' -gt 0){$fInf.fontSizeY=[Int16]'%%~.'}^
  687. %===% If('%%~/'){$fInf.faceName='%%~/'}^
  688. %===% [WApi]::SetCurrentConsoleFontEx($hOut,0,[ref]$fInf);}^
  689. %=% Else{(''+$fInf.fontSizeY+' '+$fInf.faceName)}^
  690. %=% [WApi]::CloseHandle($hOut);^") else setlocal EnableDelayedExpansion^&set arg=
  691. endlocal &set "setfont=%setfont%"
  692. if !!# neq # set "setfont=%setfont:^^!=!%"
  693. exit /b
Add Comment
Please, Sign In to add comment