[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
虽然没能做到每秒刷屏,已经很不错了,我想过做,结果没做出来。
加分!

TOP

我来提提速,把图形初始化放在循环外,利用setlocal enabledelayedexpansion和endlocal来恢复变量

分和秒防前导0错误可以这样避免:set/a sec=1!time:~6,2!-100


另外有些地方还可以提速,

1。分针和时针,也可以像秒针一样采用触发绘出
2。以“行”为单位存放图形数据,利用串截取再重组方式来更新显示点,这样可以避免刷屏时对每个点都要用set 来重组一次,并且可以减少变量占用空间和变量的数量

这样改进后,每秒刷5次屏应该都可以。我没有时间搞了,看楼主的吧。



  1. @echo off
  2. msg %username% /time:60 请右键单击时钟窗口标题栏, 选择“属性”-^>“字体”选项卡,“点阵字体”,大小: 6 x 12,以得到更好的显示效果
  3. title 指针时钟 2.0 by neorobin 叶结点
  4. setlocal enabledelayedexpansion
  5. color 9f
  6. set /a "size=19, HandS=size-1, HandM=HandS-4, HandH=HandM-4, rScale=size-1"
  7. set /a "xStart=size, xEnd=-size, yStart=-size, yEnd=size"
  8. set /a "Cols=(size*2+1)*2, Lines=size*2+1+1"
  9. (set PntCenter=◎)&(set PntH=●)&(set PntM=○)&(set PntS=·)&(set PntB=▓)
  10. (set RomanNumbers=ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ)
  11. set /a "leftSpaces=(size*2+1-13)/2-2" & (set Blanks=)
  12. for /l %%i in (1,1,!leftSpaces!) do (set Blanks=!PntB!!Blanks!)
  13. mode con cols=!Cols! Lines=!Lines!
  14. call :math
  15. if %time:~6,2% geq 10 (set sec=%time:~6,2%) else (set sec=%time:~7,1%)
  16. (call :clrScr scr !PntB!)
  17. rem 标12个刻度
  18. for /l %%z in (0,1,11) do (
  19.   (set /a angle=%%z+1) && (set /a angle*=30)
  20.   set /a "x=cos!angle!*rScale/factor, y=sin!angle!*rScale/factor"
  21.   set "scr_!x!_!y!=!RomanNumbers:~%%z,1!"
  22. )
  23. :loop
  24. (set sec1=!sec!)
  25. setlocal enabledelayedexpansion
  26. for %%i in (h,m,s) do (call :drawHand !Hand%%i! %%i)
  27. set "scr_0_0=!PntCenter!"
  28. (set strScr=)
  29. for /l %%x in (!xStart!,-1,!xEnd!) do for /l %%y in (!yStart!,1,!yEnd!) do (
  30.   (set strScr=!strScr!!scr_%%x_%%y!)
  31. )
  32. cls&(set /p=!strScr!  !Blanks!  !date! !time:~0,-3!  !Blanks!<NUL)
  33. endlocal
  34. :testSec
  35. ::if %time:~6,2% geq 10 (set sec=%time:~6,2%) else (set sec=%time:~7,1%)
  36. set/a sec=1!time:~6,2!-100&if !sec! neq !sec1! (goto loop) else goto testSec
  37. exit /b
  38. rem ========== end of main program =================================================================
  39. :math
  40. set /a "sin0=0,sin6=105,sin12=208,sin18=309,sin24=407,sin30=500,sin36=588,sin42=669,sin48=743,sin54=809,sin60=866,sin66=914,sin72=951,sin78=978,sin84=995,sin90=1000"
  41. (set /a factor=1000)
  42. for /l %%i in (0, 6, 90) do (
  43.   set /a "a1=180-%%i, a2=180+%%i, a3=360-%%i"
  44.   set /a "sin!a1!=!sin%%i!, sin!a2!=-!sin%%i!, sin!a3!=-!sin%%i!"
  45. )
  46. for /l %%i in (0, 6, 360) do (
  47.   set /a "a4=450-%%i, a4%%=360"
  48.   set /a "cos%%i=sin!a4!"
  49. )
  50. exit /b
  51. rem drawHand !HandLength! !HandFlag!
  52. :drawHand
  53. (set timeh=!time:~0,2!)&(set timem=!time:~3,2!)&(set times=!time:~6,2!)
  54. for %%i in (h,m,s) do if !time%%i! lss 10 (set time%%i=!time%%i:~-1!)
  55. set /a "timeh%%=12"
  56. set /a "angleh=30*timeh+(timem+6)/12*6, anglem=6*timem, angles=6*times"
  57. set /a "xE=%1*cos!angle%2!*2/factor, yE=%1*sin!angle%2!*2/factor"
  58. call :line scr 0 0 !xE! !yE! %1 !Pnt%2!
  59. exit /b
  60. rem clrScr scr !strBlank!
  61. :clrScr
  62. for /l %%x in (!xStart!,-1,!xEnd!) do for /l %%y in (!yStart!,1,!yEnd!) do (
  63.   (set /a inDial=size*size-%%x*%%x-%%y*%%y+1*size)&& if !inDial! geq 0 (set scr_%%x_%%y=!PntB!) else (set scr_%%x_%%y=  )
  64. )
  65. exit /b
  66. rem line scr x1 y1 x2 y2 !LenHand! !PointChr!
  67. :line
  68. (set x0=%2)&(set y0=%3)&(set x1=%4)&(set y1=%5)&(set /a SQLenHand=%6*%6)
  69. set /a "steep=(y1 - y0)*(y1 - y0) - (x1 - x0)*(x1 - x0)"
  70. if !steep! gtr 0 (
  71.   (set tt=!x0!&& set x0=!y0!&& set y0=!tt!)
  72.   (set tt=!x1!&& set x1=!y1!&& set y1=!tt!)
  73. )
  74. if !x0! gtr !x1! (
  75.   (set tt=!x0!&& set x0=!x1!&& set x1=!tt!)
  76.   (set tt=!y0!&& set y0=!y1!&& set y1=!tt!)
  77. )
  78. set /a "deltax=x1-x0, twoDeltax=2*deltax"
  79. set /a "twoDeltay=2*(y1-y0)" && (set twoDeltay=!twoDeltay:-=!)
  80. set /a "eps=0, y=y0"
  81. if !y0! lss !y1! (set yStep=1) else (set yStep=-1)
  82. for /l %%x in (!x0!,1,!x1!) do (
  83.   set /a "SQSum=%%x*%%x+y*y"
  84.   if !SQSum! leq !SQLenHand! (
  85.     if !steep! gtr 0 (set "%~1_!y!_%%x=%7") else (set "%~1_%%x_!y!=%7")
  86.   )
  87.   (set /a eps+=twoDeltay)
  88.   if !eps! gtr !deltax! (set /a "y+=yStep, eps-=twoDeltax")
  89. )
  90. exit /b
复制代码

TOP

楼主,7楼代码不正常,请检查一下。

一维串操作,设x为行,y为列,
set /a y0=y-1
for /f "tokens=1,2,3" %%x in ("!x! !y! !y0!") do (
    set line%%x=!line%%x:~,%%z!点!line%%x:~%%y!
)


另外,如果附件和贴出来的代码是一样的话,请不要上传附件,以节约论坛空间。谢谢配合。

TOP

返回列表