标题: [游戏娱乐] 二进制螺旋Binary spiral [打印本页]
作者: aa77dd@163.com 时间: 2016-9-24 00:55 标题: 二进制螺旋Binary spiral
本帖最后由 aa77dd@163.com 于 2016-9-24 01:08 编辑
第 36 行 变量 sumOfStream 的值越大, 运行效果就越接近 我贴的图, 即螺线在屏幕上铺得越满, 有 螺旋星系 的感觉, 但运行也就会越慢- @echo off & title %~n0 & setlocal enabledelayedexpansion
-
- set "hexWid=50" & set "hexHei=3c" & REM 80,60
-
- for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
- if "%1"=="" (
- for %%a in ( FontSize:00080008
- FontFamily:00000030
- WindowSize:00%hexHei%00%hexWid%
- ScreenColors:0000000a
- CodePage:000001b5
- ScreenBufferSize:00%hexHei%00%hexWid%
- FullScreen:!FullScreen:-=!
- ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
- >nul reg add HKCU\Console\TheMatrix /v %%b /t reg_dword /d 0x%%c /f
- )
- start "TheMatrix" /max "%ComSpec%" /c %~s0 1 & exit
- ) else ( >nul reg delete HKCU\Console\TheMatrix /f )
-
- REM "Main Title/Trinity Infinity" – 3:54
- if exist "%~dp0matrix4.mp3" (
- cd /d "%ProgramFiles%\Windows Media Player\"
- start /min wmplayer.exe "%~dp0matrix4.mp3"
- ) else (
- start /min http://pisa.ucsd.edu/cse125/2001/cse190g1/matrix4.mp3
- )
-
- set "Path=%SystemRoot%\system32"
- for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" if /i "%%a" neq "hexHei" if /i "%%a" neq "hexWid" set "%%a="
-
- REM trigonometric function
- set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
- set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"
- set /a "ZM=10000, p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1, DEG=31416/180"
-
- set /a "wid=0x%hexWid%, hei=0x%hexHei%, iMax=wid*hei, XC = wid/2, YC = hei/2, sumOfStream=40"
-
- set /a buffwid = wid
- set /a linesWantBackAbove = hei - 1
- set /a "cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
-
- set "TAB= "
- for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
- REM set "BS="
-
- set "BSs="
- for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
-
- set "aLineBS="
- for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
-
- set "scr="
- for /l %%i in (1 1 !iMax!) do set "scr= !scr!"
-
- for /l %%n in (1 1 !sumOfStream!) do set "TL%%n=0"
-
- set /a "DEG_unit=3, lineHeiMax = 360 / DEG_unit / 2"
-
- for /l %%* in () do (
- for /l %%n in (1 1 !sumOfStream!) do (
- if !TL%%n! leq 1 (
- rem TL 总寿命结束, 重生 Rg 生长点位置; Rc 擦除点位置
- set /a "H%%n=!random! %% (lineHeiMax-45)+45,}%%n=0,CL%%n=!random! %% (H%%n -40) + 41,TL%%n=CL%%n+H%%n,H%%n+=1, {%%n=!random! %% 360 * DEG, Rg%%n=}%%n,Rc%%n=}%%n"
- )
-
- REM 当 0 < H, grow=-1, 继续生长; 否则, grow=0, 停止生长
- REM 当 CL < 1, old=-1, 开始擦除; 否则, old=0, 不擦除
- REM 当 CL = 0, old0=-1, 擦除点位置=出生点位置; 否则, old0=0, 擦除点位置=擦除点位置, 不变
- set /a "TL%%n-=1,CL%%n-=1,H%%n-=1,old=(CL%%n-1)>>31,grow=-H%%n>>31, old0=-^!CL%%n,Rc%%n=(old0&}%%n)|(~old0&Rc%%n)"
-
- if !old! neq 0 (set "chrc= ") else set "chrc="
-
- if !grow! neq 0 ( set /a "chrg= !random! & 1" ) else set "chrg="
-
- for %%i in (g c) do if defined chr%%i (
- REM 画生长点 或 擦除点
-
- set /a "U%%i%%n={%%n + p2 + (R%%i%%n - }%%n) * DEG_unit*DEG, U%%i%%n %%= p2, U%%i%%n += U%%i%%n>>31&p2, t=U%%i%%n, s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), SINt=%SIN%, t=%COS%, COSt=(-t&s1)+(t&~s1), x=(XC*ZM + R%%i%%n * COSt)/ZM, y=(YC*ZM + R%%i%%n * SINt)/ZM, inScr=(x-0^x-wid)&(y-0^y-hei)"
-
- if !inScr! lss 0 (
- set /a "ind=x+y*wid+1, lenL=ind-1, lenR=iMax-ind"
- for /f "tokens=1,2,3" %%a in ("!lenL! !ind! !lenR!") do (set scr=!scr:~0,%%a!!chr%%i!!scr:~%%b,%%c!)
- )
-
- REM 生长点 或 擦除点变化到下一个位置
- set /a "R%%i%%n+=1"
- )
- )
-
- <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
- <nul set /p "=%BS%!scr:~0,-1!"
- )
- exit
复制代码
作者: 523066680 时间: 2016-9-24 08:57
本帖最后由 523066680 于 2016-9-24 12:24 编辑
GL乱入,固定渲染管线|双缓冲
参考
罗马花椰菜与螺纹点阵, 费氏数列与黄金分割
作者: happy886rr 时间: 2016-9-24 10:52
不错,赞一个。就是感觉sin、cos什么的可以交给C代码计算。批处理算级数,既不能一次乘太多,也不能一次除太多,效率也是个问题。麦克劳林展开式可以用倍角迭代加速。用矩阵运算做个星云的3D旋转。
作者: happy886rr 时间: 2016-9-24 10:55
回复 2# 523066680
玩的真溜,GL估计还能做那种3D旋转的星尘,GDI+。exsyx也可以绘图。
作者: 523066680 时间: 2016-9-24 11:18
本帖最后由 523066680 于 2016-9-24 11:52 编辑
回复 4# happy886rr
GL应该是比一般图形接口更好用的,特别是和显卡特性函数的对接。虽然听说这一两年DX的性能逐渐超越GL,
但是GL的移动端(OpenGL ES)和网页端(WebGL)越来越普及,我在学这门技能时也越来越有信心。
同一个sin函数,每列只有1个字符,视觉上却可以看到3条 或者 2条曲线在交错
作者: happy886rr 时间: 2016-9-24 12:52
回复 5# 523066680
溜啊,对波形的驾驭力强。几乎所有曲线都可以用傅里叶级数表示为正余弦函数,什么噪音处理了,图像复原,人脸识别,都离不开sin、cos。
作者: aa77dd@163.com 时间: 2016-9-24 12:54
本帖最后由 aa77dd@163.com 于 2016-9-24 13:15 编辑
回复 2# 523066680
批处理也乱入
- @echo off & setlocal enabledelayedexpansion
-
- set "TAB= " & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
-
- set /a "ZM=10000, p=31416, p2=62832, pn2=-62832, p#2=15708, p3#2=47124, p3#2_=p3#2-1, DEG=31416/180"
- set "SIN=(t-t*t/1875*t/320000+t*t/1875*t/15625*t/16000*t/2560000-t*t/1875*t/15360*t/15625*t/15625*t/16000*t/44800000)"
- set "COS=(10000-t*t/20000+t*t/1875*t/15625*t/819200-t*t/1875*t/15360*t/15625*t/15625*t/10240000+t*t/1875*t/15360*t/15625*t/15625*t/16000*t/15625*t/229376000)"
-
- set /a "wid=75, hei=75, iMax=wid*hei, wid_div_2 = wid / 2 - 3"
- color 0c & mode !wid!,!hei!
-
- (for /l %%i in (1 1 !iMax!) do set "scr= !scr!") & set "emp=!scr!"
-
- set /a "buffwid = wid, linesWantBackAbove = hei - 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
-
- set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
- set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
-
- set /a "XC = wid/2, YC = hei/2, DEG_unit = 3, ddu=1, th0=!random! %% 360 * DEG"
-
- for /L %%i in (5000 -1 0) do (
-
- set /a "th=th0+p2+DEG*%%i, DEG_unit+=ddu, DEG_unit= DEG_unit %% 360"
-
- for /l %%a in (0 1 !wid_div_2!) do (
- set /a "th+=p2+DEG * DEG_unit, th %%= p2, th += th>>31&p2, t=th, s1=(t-p#2^t-p3#2)>>31, s3=p3#2_-t>>31, t=(-t&s1)+(t&~s1)+(p&s1)+(pn2&s3), SINt=%SIN%, t=%COS%, COSt=(-t&s1)+(t&~s1)"
-
- set /a "r=%%a, x=(XC*10000 + r * COSt)/10000, y=(YC*10000 + r * SINt)/10000, inScr=(x-0^x-wid)&(y-0^y-hei)"
-
- REM if !inScr! lss 0 (
- set /a "ind=x+y*wid+1, lenL=ind-1, lenR=iMax-ind"
- for /f "tokens=1,2,3" %%a in ("!lenL! !ind! !lenR!") do (set scr=!scr:~0,%%a!*!scr:~%%b,%%c!)
- REM )
- )
-
- <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
- <nul set /p "=%BS%!scr:~0,-1!" & set "scr=!emp!" & title %%i / 5000
- )
- >nul pause
- exit
复制代码
作者: 依山居 时间: 2016-9-24 15:04
羡慕嫉妒恨,只能静静看着你们装B。
作者: 523066680 时间: 2016-9-24 15:25
本帖最后由 523066680 于 2016-9-25 00:22 编辑
回复 8# 依山居
我也很嫉妒的,决定回去慢慢结网。话说你python跑个图像很轻松啊
http://bbs.bathome.net/redirect.php?goto=findpost&ptid=15549&pid=102495
(以前照搬改写了一些教程,可惜烂尾了。以及,现在看以前的帖子,感觉 too young too naive
再贴一个三维旋转体
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |