- @echo off
- color 0a
- ::::::::绘制矩形 {s11ss 2007-10-12}::::::::
- setlocal enabledelayedexpansion
- if "%1" equ "/?" (
- call :help
- echo 例如:%0 * 8 500
- goto :eof
- )
-
- ::设置变量:
- if "%1" equ "" (
- call :help
- echo 现在就输入参数,如* 8 500:
- set/p s=
- for /f "tokens=1,2* delims= " %%a in ("!s!") do (
- set c=%%a
- set n=%%b
- set w=%%c
- )
- ) else (
- set c=%1
- set n=%2
- set w=%3
- )
- set/a r=%n%-2
- for /l %%a in (1,1,%n%) do (
- set up=!up!%c%
- for /l %%i in (1,1,%%a) do set down%%a=!down%%a!%c%
- set/a t=%n%-%%a
- ::pause
- for /l %%z in (1,1,!t!) do set down%%a= !down%%a!
- if %%a leq %r% set space%r%= !space%r%!
- )
- set mid1=!space%r%! %c%
- set mid2=%c%!space%r%!%c%
-
- ::分四步绘制:
- ::1.上边的棱
- for /l %%a in (1,1,%n%) do (
- cls
- echo !up:~0,%%a!
- call :delay
- )
- ::2.右边的棱
- >t.x echo !up!
- for /l %%a in (1,1,%n%) do (
- if %%a leq %r% (
- echo !mid1!
- >>t.x echo !mid1!
- call :delay
- )
- )
- ::3.下边的棱
- for /l %%a in (1,1,%n%) do (
- cls
- type t.x
- echo !down%%a!
- call :delay
- )
- ::4.左边的棱
- for /l %%a in (1,1,%n%) do (
- if %%a leq %r% (
- cls
- echo !up!
- set/a t=%r%-%%a
- for /l %%i in (1,1,!t!) do (
- echo !mid1!
- )
- for /l %%z in (1,1,%%a) do (
- echo !mid2!
- )
- echo !up!
- call :delay
- )
- )
-
- ::结束:
- del t.x
- pause>nul
- goto :eof
-
- ::函数部分:
- :delay
- for /l %%x in (1,1,%w%) do (echo Waiting...>nul)
- goto :eof
-
- :help
- echo 参数一:用于显示的字符,如*。
- echo 参数二:一行字符的个数,如8。
- echo 参数三:字符之间的延时,如500。
复制代码