[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. xianshixia
复制代码

TOP

我试试
  1. woshishi
复制代码

TOP

  1. echo 试下
复制代码

TOP

  1. 我试试。。
复制代码

TOP

指针式时钟

我想发这份代码, 可这里居然还要我有少尉等级, 要过500分, 我懒得等积分啊, 就这里发了.

目前尚未找到更高效的指针绘图方法, 时钟的指针绘图刷新所需 10 秒左右(几秒到十几秒), 秒针的显示已失去意义, 故只显示时针和分针, 字体请使用 CMD 默认的 8X16 字体, 至少请使用和这个宽高比相同的字体, 以得到最理想的显示效果
  1. :: 指针时钟 作者: neorobin   neorobin@163.com   http://hi.baidu.com/leafnode
  2. :: 指针绘图核心算法: Bresenham 直线算法
  3. @echo off
  4. title 批处理时钟 by neorobin
  5. setlocal enabledelayedexpansion
  6. color 9f
  7. rem 6°间隔坐标表: 行偏移*字体宽*1000, 列偏移*字体高*10. 此变化可保证指针等长显示, 表盘呈圆形而非椭圆.
  8. set table=-80,0,-80,17,-78,33,-76,49,-73,65,-69,80,-65,94,-59,107,-54,119,-47,129,-40,139,-33,146,-25,152,-17,157,-8,159,0,160,8,159,17,157,25,152,33,146,40,139,47,129,54,119,59,107,65,94,69,80,73,65,76,49,78,33,80,17,80,0,80,-17,78,-33,76,-49,73,-65,69,-80,65,-94,59,-107,54,-119,47,-129,40,-139,33,-146,25,-152,17,-157,8,-159,0,-160,-8,-159,-17,-157,-25,-152,-33,-146,-40,-139,-47,-129,-54,-119,-59,-107,-65,-94,-69,-80,-73,-65,-76,-49,-78,-33,-80,-17,
  9. set tableLen=444
  10. set Dial=20,69,196,398,596,709,740,691,564,362,164,51,
  11. set DialLen=45
  12. set PointChr=.
  13. set Width=40
  14. set Height=20
  15. set Height1=21
  16. set minPinLen=8
  17. set hourPinLen=5
  18. mode con cols=!Width! Lines=!Height1!
  19. set /a scrMax=Width*Height
  20. set /a FontHWR=16/8
  21. set /a SQFontHWR=FontHWR*FontHWR
  22. set /a ColO=Width/2
  23. set /a LinO=Height/2
  24. set /a centre=(LinO-1)*Width+ColO
  25. set centreChr=o
  26. :nextMin
  27. if %time:~0,2% geq 10 (set hour=%time:~0,2%) else set hour=%time:~1,1%
  28. if %time:~3,2% geq 10 (set min=%time:~3,2%) else set min=%time:~4,1%
  29. if %time:~6,2% geq 10 (set sec=%time:~6,2%) else set sec=%time:~7,1%
  30. set min1=!min!
  31. set sec1=!sec!
  32. set scrPointList=!Dial!
  33. set /a scrPointListLen=DialLen
  34. set /a PinLen=minPinLen
  35. set /a SQPinLen=PinLen*PinLen
  36. call :searchDIR LinOffs ColOffs !tableLen! !min!
  37. call :line 0 0 !LinOffs! !ColOffs! scrPointList scrPointListLen
  38. set hourScale=!hour!
  39. if !hourScale! geq 12 set /a hourScale-=12
  40. set /a hourScale=hourScale*30+min*30/60
  41. set /a hourScale/=6
  42. set /a PinLen=hourPinLen
  43. set /a SQPinLen=PinLen*PinLen
  44. call :searchDIR LinOffs ColOffs !tableLen! !hourScale!
  45. call :line 0 0 !LinOffs! !ColOffs! scrPointList scrPointListLen
  46. set Value=0
  47. set List=!scrPointList!
  48. set Length=!scrPointListLen!
  49. cls
  50. for /l %%i in (1,1,!scrMax!) do (
  51.   set findPoint=0
  52.   for /l %%z in (0,1,!Length!) do (
  53.     set Value=!Value!!List:~%%z,1!
  54.     if "!List:~%%z,1!"=="," (
  55.       set Value=!Value:~0,-1!
  56.       if !Value! equ %%i if !findPoint! equ 0 (
  57.         if !Value! equ !centre! (set /p=!centreChr!<nul) else set /p=!PointChr!<nul
  58.         set findPoint=1
  59.       )
  60.       set Value=
  61.     )
  62.   )
  63.   if !findPoint! equ 0 set /p= <nul
  64. )
  65. set /p=       !date! %time:~0,-3%<nul
  66. :nextSec
  67. if %time:~3,2% geq 10 (set min=%time:~3,2%) else set min=%time:~4,1%
  68. if %time:~6,2% geq 10 (set sec=%time:~6,2%) else set sec=%time:~7,1%
  69. if !sec! neq !sec1! (
  70.   set sec1=!sec!
  71.   rem 更新秒数字显示
  72.   set /p=%time:~6,2%<nul
  73. )
  74. if !min! neq !min1! (goto nextMin) else goto nextSec
  75. goto :eof
  76. :line
  77. set x0=%1&&set y0=%2&&set x1=%3&&set y1=%4
  78. set /a steep=(y1 - y0)*(y1 - y0) - (x1 - x0)*(x1 - x0)
  79. if !steep! gtr 0 (
  80.   set ttt=!x0!&& set x0=!y0!&& set y0=!ttt!
  81.   set ttt=!x1!&& set x1=!y1!&& set y1=!ttt!
  82. )
  83. if !x0! gtr !x1! (
  84.   set ttt=!x0!&& set x0=!x1!&& set x1=!ttt!
  85.   set ttt=!y0!&& set y0=!y1!&& set y1=!ttt!
  86. )
  87. set /a deltax=x1-x0
  88. set /a twoDeltax=2*deltax
  89. set /a twoDeltay=2*(y1-y0)
  90. if !twoDeltay! lss 0 set /a twoDeltay=-twoDeltay
  91. set /a eps=0
  92. set /a y=y0
  93. if !y0! lss !y1! (set yStep=1) else set yStep=-1
  94. for /l %%x in (!x0!,1,!x1!) do (
  95.   if !steep! gtr 0 (set /a SQSum=%%x*%%x/SQFontHWR+y*y) else set /a SQSum=%%x*%%x+y*y/SQFontHWR
  96.   if !SQSum! leq !SQPinLen! (
  97.     if !steep! gtr 0 (
  98.       set /a scrii=LinO+y-1
  99.       set /a scrii=scrii*Width+ColO+%%x
  100.     ) else (
  101.       set /a scrii=LinO+%%x-1
  102.       set /a scrii=scrii*Width+ColO+y
  103.     )
  104.     set %5=!scrii!,!%5!
  105.     set /a %6+=1
  106.     for /l %%z in (1,1,10) do (
  107.       if !scrii! gtr 0 set /a %6+=1
  108.       set /a scrii/=10
  109.     )
  110.   )
  111.   set /a eps+=!twoDeltay!
  112.   if !eps! gtr !deltax! (
  113.     set /a y+=!yStep!
  114.     set /a eps-=!twoDeltax!
  115.   )
  116. )
  117. goto :eof
  118. rem end of :line
  119. :searchDIR
  120. rem 调用语法 call :searchDIR LinOffs ColOffs %tableLen% %index%
  121. rem index 为索引, 用分或秒或时的对应的索引值替换
  122. set /a ii=%4*2
  123. set /a jj=ii+1
  124. set test=-1
  125. set OffsValue=
  126. for /l %%z in (0,1,%3) do (
  127.   set OffsValue=!OffsValue!!table:~%%z,1!
  128.   if "!table:~%%z,1!"=="," (
  129.     set /a test+=1
  130.     set OffsValue=!OffsValue:~0,-1!
  131.     if !test! equ !ii! set /a %1=OffsValue
  132.     if !test! equ !jj! set /a %2=OffsValue
  133.     set OffsValue=
  134.   )
  135. )
  136. goto :eof
复制代码

TOP

(code)
我来试试…………
(/code)

TOP

[code]
my good!
[code]

TOP

  1. I'm sorry! Let me try it again!
复制代码

TOP

  1. echo off
  2. echo 俺明白了,哈哈
  3. echo 谢谢
复制代码

TOP

  1. @echo off
  2. echo 测试如何把代码用code扩起来
  3. echo 复制当前全部内容粘贴到论坛发帖即可测试。
复制代码

TOP

[@echo off]
echo 我也试一下
[pause]

TOP

{code}
@ehco off
pause
[/code]

TOP

{code}
@ehco off
pause
[/code]

TOP

  1. @echo off
  2. echo 这样就ok了,只要将开头和结尾的()换成[]就可以了
  3. pause
复制代码

TOP

  1. echo 我终于会了
复制代码

TOP

返回列表