标题: [游戏娱乐] 点阵生成、解释器批处理版 [打印本页]
作者: zhouyongjun 时间: 2009-7-9 00:21 标题: 点阵生成、解释器批处理版
前天有位兄台发了个,感觉很好玩,回家就自己写了个- @echo off&setlocal enabledelayedexpansion
- title 点阵生成-解释器
- :begin
- cls&color 3f&mode con cols=50 lines=16
- set fore=&set back=&call :blank 5
- set file=&set/p file= 拖入点阵文件到这里:
- if not defined file goto begin
- if not exist %file% goto begin
- type %file%|findstr "[0-9]"|findstr "\-" >nul 2>nul&&goto explain
- :_crate //**点阵生成编码**//
- call :foreback %file%
- call :file_name_path 编码
- >"%tee%" echo/%fore%%back%
- :crate
- cls&call :blank 5
- echo 程序检测到前景为[%fore%]背景为[%back%]
- echo 输入任意字母互换前背景,默认直接回车
- echo/&set choices=&set/p choices= please choice:
- if defined choices (call :change back fore&goto crate)
- for /f "delims=" %%a in ('findstr/n ".*" "%_path%"') do (
- set "var=%%a"&set var=!var:*:=!&set "m="&set "n="
- if defined var (call :totext&echo/>>"%tee%") else echo/>>"%tee%"
- )
- echo/&echo 生成编码成功!
- ping /n 2 127.1>nul&goto begin
- :explain //**编码解释成点阵**//
- cls&call :blank 5
- echo 输入任意字母彩色显示,默认颜色直接回车
- echo/&set input=&set/p input= please input:
- cls&mode con cols=120 lines=60
- call :file_name_path
- set/p fb=<"%_path%"
- set "fore=%fb:~,1%"&set "back=%fb:~1%"
- if defined input <nul set/p= >%fore%
- for /f "skip=1 delims=" %%a in ('findstr/n ".*" "%_path%"') do (
- set "_var=%%a"&set _var=!_var:*:=!
- if defined _var (
- for %%b in (!_var!) do (
- if %%b gtr 0 (for /l %%c in (1,1,%%b) do <nul set/p=%back%) else (
- if defined input (
- set "_color=0123456789abcdef"
- set/a x=!random!%%16
- for %%i in (!x!) do set "_color=!_color:~%%i,1!"
- for /l %%c in (%%b,1,-1) do findstr /a:!_color! . %fore%*
- ) else (for /l %%c in (%%b,1,-1) do <nul set/p=%fore%)
- )
- )
- echo/
- ) else echo/
- )
- if defined input del %fore%>nul
- call :blank 3
- pause>nul&goto begin
- :foreback //**获取前背景**//
- for /f "usebackq delims=" %%i in ("%~1") do (
- set "str=%%i"
- if not defined back set back=!str:~,1!
- call,set fore=%%str:!back!=%%
- if defined fore (
- set "fore=!fore:~,1!"
- if "!fore!" equ " " call :change back fore
- if "!fore!" equ " " call :change back fore
- goto :eof
- )
- )
- goto :eof
- :blank //**产生空行**//
- for /l %%i in (1,1,%1) do echo/
- goto :eof
- :change //**交换前背景**//
- set %1=%fore%&set %2=%back%&goto :eof
- :file_name_path //**文件名称,路径格式化**//
- for %%i in (%file%) do (set "dire=%%~dpi"&set "_path=%%~fi"&set "tee=!dire!%%~ni_%1.txt")
- goto :eof
- :totext //**逐个截取统计成编码写入文本**//
- if defined var (
- set #var=%var:~,1%
- if "!#var!" neq "%fore%" (
- set/a n+=1&if defined m (>>"%tee%" <nul set/p=-%m% &set "m=")
- ) else (set/a m+=1&if defined n (>>"%tee%" <nul set/p=%n% &set "n=")
- )
- set var=!var:~1!
- goto totext
- )
- if defined n (>>"%tee%" <nul set/p=%n% ) else (
- >>"%tee%" <nul set/p=-%m%
- )
- goto :eof
复制代码
测试文本-
-
- ▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓▓▓
- ▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓ ▓ ▓
- ▓▓▓▓ ▓ ▓ ▓▓▓▓ ▓ ▓ ▓▓▓▓▓▓▓
- ▓ ▓ ▓ ▓ ▓ ▓ ▓▓ ▓ ▓ ▓ ▓
- ▓ ▓▓ ▓▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓ ▓ ▓
- ▓▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓▓▓
- ▓▓▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
- ▓ ▓ ▓ ▓ ▓ ▓ ▓▓▓▓▓
- ▓ ▓ ▓▓ ▓ ▓ ▓ ▓▓ ▓
- ▓ ▓▓ ▓ ▓ ▓ ▓▓ ▓ ▓▓ ▓
- ▓▓▓ ▓ ▓▓▓ ▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓▓▓
-
-
复制代码
随风代码中的几个字-
- ● ● ● ●●●● ●●●●●●●●● ● ●
- ● ● ● ●●●●● ● ● ● ●●●●●●●●●●●
- ● ● ● ● ●●●● ● ● ●
- ●●●●●●●●● ● ● ● ● ● ● ● ●
- ●● ● ●●●● ● ●● ●●●●●●●●●●● ●●● ●●●
- ● ● ● ● ● ● ● ● ●
- ● ●● ●●●●●●●●● ● ● ●●●● ●●●●●
- ● ● ● ● ● ●
- ● ● ● ●●●●●●● ● ● ● ● ● ●●
- ● ● ● ● ● ● ● ● ● ● ●
- ●● ● ●●●●●●●●●●● ●● ●● ● ●●●●●● ●
-
-
-
- ● ● ● ● ● ● ● ●
- ● ● ●●●● ● ● ● ● ● ●
- ●●●●●●●●● ● ● ●●●●●●●●● ●● ● ●
- ●● ● ●●●●●●●●●●● ● ● ● ● ● ●●● ●
- ●● ● ● ● ● ● ● ●●● ● ●
- ● ● ●●●●● ● ●● ● ● ● ● ● ●●●●●
- ● ●● ● ●●● ● ● ●●●●●●●●● ●
- ●● ● ● ●● ● ● ● ●●●●●●●●●●●
- ● ● ● ● ●● ● ● ●
- ● ● ● ●●● ● ● ● ●
- ● ●●●●● ●●● ●● ● ●
-
-
复制代码
不能插入截图,是不是等级不够啊
如要交换前背景,即反色显示,必须前背景全半角一致
代码完全是自己的思路,如有雷同纯属巧合!
更新了下,增加了彩色显示功能。。。
作者: Batcher 时间: 2009-7-9 09:17
你的级别可以插入截图。
是不是图片格式不对?或者体积太大?
关于如何压缩图片,可参考:http://bbs.bathome.net/thread-4673-1-1.html
作者: zhouyongjun 时间: 2009-7-9 10:24
不能插入本地图片吧?
算了,节约论坛空间。。。
作者: zhouyongjun 时间: 2009-7-13 00:01
周末在家无聊,觉上面那玩意儿必须要有点阵文字。自己设计浪费时间,也不好弄。
在网上没找到能生成文本点阵文字比较如意的软件;有在线生成的,文字多也不好用。
后面找到一个这样的东西,可以复制汉字或者英文进去很快生成由数字“1”组成的点阵文字,但是全部一列显示,而且前面还有一列十六进制数字。
http://cachefile26.rayfile.com/z ... 647e442/fontgen.rar(146KB)
那是高级语言里面的什么东西,我不懂,拿过来凑合着用,但是要经过处理
下面是我写的处理用的代码,可以更改每行显示几个字
我试过1024*768的分辨率下记事本最大化,一行最多4个汉字。- @echo off&setlocal enabledelayedexpansion
- ::设置字体高度、宽度、每行显示文字个数;可在下面修改
- set/a high=16,wide=16,per=3
- title 生成点阵字
- color 3f&mode con cols=50 lines=16
- echo/&echo/&echo/&echo/
- echo/ 把要处理的点阵文件拖到这里!
- set/p file=
- for /f "tokens=3" %%a in ('find/c " " %file%') do set "row=%%a"
- for %%i in (%file%) do set "tee=%%~dpi\%%~ni_点阵.txt"
- set/a row+=(per-1)*high
- echo/>nul 3>"%tee%"
- :loop //**n为当前读取行,m为当前读取字**//
- call :distill %file%
- set/a m+=1
- if "%m%" equ "%per%" (
- set/a m=0,line+=1,mod=line%%high
- if "!mod!" equ "0" set/a line=n+1
- echo/
- )
- set/a n=high*m+line
- set "_skip=skip=%n%"
- if "%n%" neq "%row%" goto loop
- exit
- :distill //**提取字符各部分拼凑到一行**//
- for /f "%_skip% usebackq delims=" %%a in ("%~1") do (
- set "str=%%a"
- if "!str:~2,1!" equ " " (set "str=!str:~-16!") else (set "str=!str:~-32!")
- set "str=!str:11=▓!"&set "str=!str: = !"&set "str=!str: =!"
- <nul set/p=!str!&goto :eof
- )
复制代码
[ 本帖最后由 zhouyongjun 于 2009-7-13 12:33 编辑 ]
作者: shenlong 时间: 2009-10-23 20:14
各位,这拖入的文件是啥格式的。
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |