Board logo

标题: [特效代码] 批处理特效之“看我倒背如流” [打印本页]

作者: batman    时间: 2013-8-16 23:47     标题: 批处理特效之“看我倒背如流”

本帖最后由 batman 于 2013-8-17 00:02 编辑

&&相信大家都知道倒背如流的意思吧,下面我们就用批来模拟对文本的倒背特效:
  1. @echo off&setlocal enabledelayedexpansion
  2. rem 因论坛处理不了制表符,请将下面tab=后面的空格替换为制表符再运行代码
  3. set "tab= "
  4. for /l %%a in (10000,1,11000) do (
  5.   set "tg=!tg!"&set "k=!k! "
  6.   set "str=%%a"&set "code=!str:~1!!code!"
  7. )
  8. echo,&echo,┌────────────────────┐
  9. echo,&echo,└────────────────────┘
  10. echo,%tab%%tg:~,24%
  11. for /l %%a in (1,1,20) do (
  12.   set /a bf=%%a*5,n=40-2*%%a
  13.   set /p=!tg!│<nul
  14.   for /l %%b in (1,1,%%a) do set /p=■<nul
  15.   for %%i in (!n!) do set /p=!k:~,%%i!│文本阅读中,请稍等...!bf!%%<nul
  16.   for /l %%c in (1,1,2000) do echo,>nul
  17. )
  18. cls&&echo,&echo,下面且看我倒背如流:&echo,
  19. for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
  20.   set "_%%a=%%b"&set /a n=%%a&echo,
  21. )
  22. for /l %%a in (%n%,-1,1) do (
  23.   set /a s=n-%%a+1,m=s*10+12
  24.   for /l %%b in (1,1,!s!) do echo,
  25.   for %%b in (!m!) do echo,%tab%!tg:~,%%b!
  26.   if defined _%%a (
  27.     set "str=!_%%a!!_%%a!!_%%a!!_%%a!%code%"
  28.     set /a sw=1!str:~4000,4! %% 10000
  29.     for /l %%b in (1,1,!sw!) do (
  30.       set /a kw=sw-%%b
  31.       for %%c in (!kw!) do set /p=!k:~,%%c!!_%%a:~-%%b,%%b!<nul
  32.       for /l %%c in (1,1,200) do echo,>nul
  33.       set /p=!tg!<nul
  34.     )
  35.   )
  36. )
  37. pause>nul
复制代码
暂只适用于每行少于80个字符的纯英文文本,测试文本a.txt如下:
  1. I loved you, and I probably still do,
  2. And for a while the feeling may remain...
  3. But let my love no longer trouble you,
  4. I do not wish to cause you any pain.
  5. I loved you; and the hopelessness I knew,
  6. The jealousy, the shyness - though in vain -
  7. Made up a love so tender and so true
复制代码

作者: 523066680    时间: 2013-8-17 08:28

本帖最后由 523066680 于 2013-8-17 09:20 编辑

闲情雅致啊。
很自然。做点阵渐显应该比cls刷新快。
已经不再用批处理弄这些了
作者: 112    时间: 2018-3-9 16:06

6666666666666




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