Board logo

标题: [游戏娱乐] 批处理实现贝塞尔曲线对称变幻艺术 [打印本页]

作者: aa77dd@163.com    时间: 2016-10-4 16:05     标题: 批处理实现贝塞尔曲线对称变幻艺术

在老料 ( http://bbs.bathome.net/thread-41913-1-1.html ) 的基础上加上了简单的对称处理

无论你懂不懂艺术, 对称就是一种简单易行的艺术构造方式

  1. @echo off & setlocal enabledelayedexpansion & color 0A & chcp 437
  2. set "hexWid=65" & set "hexHei=43" & REM 101 x 67
  3. for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
  4. if "%1"=="" (
  5.     for %%a in ( FontSize:00060004 FontFamily:00000030 WindowSize:00%hexHei%00%hexWid% ScreenColors:0000000a CodePage:000001b5 ScreenBufferSize:00%hexHei%00%hexWid% FullScreen:!FullScreen:-=!
  6.     ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do >nul reg add HKCU\Console\Bezier_CMD /v %%b /t reg_dword /d 0x%%c /f
  7.     start "Bezier_CMD" /max "%ComSpec%" /c %~s0 1 & exit
  8. ) else ( >nul reg delete HKCU\Console\Bezier_CMD /f )
  9. set "Path=%SystemRoot%\system32" & for /f "delims==" %%a in ('set') do if /i "%%a" neq "Path" if /i "%%a" neq "hexWid" if /i "%%a" neq "hexHei" set "%%a="
  10. set /a "pixel_w=4, pixel_h=6" & rem FontSize 4X6
  11. set /a "Cols=wid=0x%hexWid%, lines=hei=0x%hexHei%, ctrl_wid=wid * 3 / 3, ctrl_hei=hei * 3 / 3, iMax=wid*hei"
  12. set /a "XC = Cols/2, YC = lines/2"
  13. (for /l %%i in (1 1 !wid!) do set "t= !t!") & (for /l %%i in (1 1 !hei!) do set "scr=!scr!!t!") & set "t="
  14. set "TAB= " & for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "BS=%%a"
  15. set /a "buffwid = wid, linesWantBackAbove = hei - 1 + 1, cntBS = 2 + (buffwid + 7) / 8 * linesWantBackAbove"
  16. set "BSs=" & for /L %%a in (1 1 !cntBS!) do set "BSs=!BSs!%BS%"
  17. set "aLineBS=" & for /L %%a in (1 1 !wid!) do set "aLineBS=!aLineBS!%BS%"
  18. set "dic=QWERTYUIOPASDFGHJKLZXCVBNM@#$+[]{}" & set "sumLines=30" & rem sumLines ^< lenth of dic, dic: as pen, don't use syntax character
  19. set /a "DotPerLine=15, DotPerLineSQ=DotPerLine*DotPerLine, DotPerLineCube=DotPerLine*DotPerLineSQ"
  20. set /a "pathDensity=50, pathDensitySQ=pathDensity*pathDensity, pathDensityCube=pathDensitySQ*pathDensity"
  21. for /L %%h in (0 1 3) do for %%i in (0 1 3) do ^
  22. set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
  23. for /L %%j in (0 1 !DotPerLine!) do (
  24.     set /a "tr_%%j=DotPerLine-%%j,tr2_%%j=tr_%%j*tr_%%j,te2_%%j=%%j*%%j,t0_%%j=tr2_%%j*tr_%%j, t1_%%j=3*tr2_%%j*%%j, t2_%%j=3*tr_%%j*te2_%%j, t3_%%j=te2_%%j*%%j"
  25. )
  26. for /L %%# in (0) do (
  27.     for /L %%i in (1 1 !pathDensity!) do (
  28.         REM pens
  29.         set "dic=!dic:~1!!dic:~0,1!" & set "born=!dic:~%sumLines%,1!"
  30.         set /a "tr=pathDensity-%%i,tr2=tr*tr,te2=%%i*%%i,ct0=tr2*tr, ct1=3*tr2*%%i, ct2=3*tr*te2, ct3=te2*%%i"
  31.         for /L %%h in (0 1 3) do (
  32.             set /a "x%%h=(ct0*cx%%h_0+ct1*cx%%h_1+ct2*cx%%h_2+ct3*cx%%h_3)/pathDensityCube, y%%h=(ct0*cy%%h_0+ct1*cy%%h_1+ct2*cy%%h_2+ct3*cy%%h_3)/pathDensityCube"
  33.         )
  34.         REM title %%i/!pathDensity! {!x0!,!y0!},{!x1!,!y1!},{!x2!,!y2!},{!x3!,!y3!}
  35.         for /L %%j in (0 1 !DotPerLine!) do (
  36.             set /a "dx=(t0_%%j*x0+t1_%%j*x1+t2_%%j*x2+t3_%%j*x3)*pixel_h/(pixel_w*DotPerLineCube), dy=(t0_%%j*y0+t1_%%j*y1+t2_%%j*y2+t3_%%j*y3)/DotPerLineCube"
  37.             for %%u in (+ -) do for %%v in (+ -) do (
  38.                 set /a "x=XC %%u dx, y=YC %%v dy, inScr=(x-0^x-wid)&(y-0^y-hei)"
  39.                 if !inScr! lss 0 (
  40.                     set /a "ind=x+y*wid+1, lenL=ind-1"
  41.                     for /f "tokens=1,2" %%a in ("!lenL! !ind!") do (set scr=!scr:~0,%%a!!born!!scr:~%%b!)
  42.                 )
  43.             )
  44.         )
  45.         REM clear old line
  46.         for %%c in ("!dic:~0,1!") do set "scr=!scr:%%~c= !"
  47.         <nul set /p "=!aLineBS!" & (2>nul echo;%TAB%!BSs!) & <nul set /p "=%BS%"
  48.         <nul set /p "=%BS%!scr:~0,-1!"
  49.     )
  50.     for /L %%h in (0 1 3) do (
  51.         set /a "cx%%h_0=cx%%h_3, cy%%h_0=cy%%h_3, cx%%h_1 = (cx%%h_3 << 1) - cx%%h_2, cy%%h_1 = (cy%%h_3 << 1) - cy%%h_2"
  52.         for %%i in (2 3) do set /a "cx%%h_%%i=!random! %% ctrl_wid - (ctrl_wid>>1), cy%%h_%%i=!random! %% ctrl_hei - (ctrl_hei>>1)"
  53.     )
  54. )
  55. >nul pause
  56. exit
复制代码

作者: 523066680    时间: 2016-10-4 16:16

本帖最后由 523066680 于 2016-10-4 16:20 编辑

今有牛人,将数学与批处理与图形完美结合。
观众叹为观止,
此图令人菊紧。

猜应该是坐标限制范围取控制点,然后上下对称取另一组控制点,用N阶贝塞尔曲线形成一个回环?
作者: aa77dd@163.com    时间: 2016-10-4 16:22

本帖最后由 aa77dd@163.com 于 2016-10-4 16:25 编辑

回复 2# 523066680

同样是 3 次曲线, 只是原 老料只在 (x,y) 一点作图, 而这里在 (x,y), (x,-y), (-x,y), (-x,-y) 四点作图, 就形成了对称效果

关键只在一行代码, 其余几乎无改动 各用一个变量控制 x 坐标和 y 坐标 的符号
  1. for %%u in (+ -) do for %%v in (+ -) do (
复制代码

作者: 523066680    时间: 2016-10-4 16:28

回复 3# aa77dd@163.com


    了解,字符图,没辨仔细。最近你和happy君产量略高,我平均每天收藏1个批处理




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2