论文开头可以有某种thank you
内容,结尾也可以有某种内容。我不想写一些具体的东西,而是想用 ASCII 艺术以花顶开始论文,以花尾结束论文。我想用以下形状的歌词制作花朵
因此读者几乎需要用显微镜才能读懂歌词——而且在某个点上写点东西也很酷。在 LaTex 中可以做这种有创意的事情吗?是否已经内置了将 ASCII 艺术嵌入正式论文的功能?
或许相关
答案1
为什么不直接使用外部包找到你的 ASCII 艺术并逐字包含它呢?也许使用listings
的\lstinputlisting
:
\documentclass{article}
\usepackage{filecontents,listings,graphicx,varwidth}% http://ctan.org/pkg/{filecontents,listings,graphicx,varwidth}
% Source: http://www.chris.com/ascii/index.php?art=animals/birds%20(water)
\begin{filecontents*}{duck.txt}
.;;;..
;<!!!!!!!!;
.;!!!!!!!!!!!!>
.<!!!!!!!!!!!!!!!
;!!!!!!!!!!!!!!!!'
;!!!!!!!!!!!!!!!!!'
;!!!!!!!!!!!!!!!''
,!!!!!!!!!!!!!'` .::
,;!',;!!!!!!!!!!!'` .::::'' .,,,,.
!!!!!!!!!!!!!!!'`.::::' .,ndMMMMMMM,
!!!!!!!!!!!!!' .::'' .,nMMP""',nn,`"MMbmnmn,.
`!!!!!!!!!!` :'' ,unMMMM" xdMMMMMMMx`MMn
_/ `'!!!!''` ',udMMMMMM" nMMMMM??MMMM )MMMnur=
,.... ......--~ , ,nMMMMMMMMMMnMMP".,ccc, "M MMMMP' ,,
`--......-- _.' " MMP??4MMMMMP ,c$$$$$$$ ).MMMMnmMMM
_.-' _..-~ =".,nmnMMMM .d$$$$$$$$$L MMMMMMMMMP
.--~_.--~ '.`"4MMMM $$$$$$$$$$$',MMMMMPPMM
`~~~~ ,$$$h.`MM `?$$$$$$$$P dMMMP , P
<$""?$ `" $$$$$$$$',MMMP c$
`$c c$h $$$$$$$',MMMM $$
$$ $$$ $$$$$$',MMMMM `?
`$.`$$$c. z$???" "',,`"
3h $$$$$cccccccccc$$$$$$$$$$$=r
`$c`$$$$$$$$$$$$$$$??$$$$F"$$ "
,mr`$c`$$$$$$$$$$$$$$c 3$$$$c$$
,mMMMM."$.`?$$$$$$$$$$$$$$$$$$$$$$h,
;. . .uMMMMMMMM "$c,`"$$$$$$$$$$$$$$$$C,,,,cccccc,,..
!!;,;!!!!> .,,... ,nMMMMMMMMMMM.`?$c `"?$$$$$$$$$$$$$$$$$$$$$$$$$$$$h.
!!!!!!!!! uMM" <!!',dMMMMMMMMMMPP" ?$h.`::..`""???????""'.. -==cc,"?$$P
!!!!!!!!'.MMP <!',nMMMMMMMMP" .; `$$c,`'::::::::::::'.$F
!!!!!!!! JMP ;! JMMMMMMMP" .;!!' "?$hc,.````````'.,$$
!!!!'''' 4M(;',dMMMP""" ,!!!!` ;;!!;. "?$$$$$?????????"
!!! ::. 4b ,MM" .::: !''`` <!!!!!!!!;
`!::::.`' 4M':::::'',mdP <!!!!!!!!!!!;
! :::::: .. :::::: ""'' <!!!!!!!!!!!!!!;
!! ::::::.::: .::::: ;!!> <!!!!!!!!!!!!!!!!!;.
!! :::::: `:'::::::!!' <!!!!!!!!!!!!!!!!!!!!!;;.
! ::::::' .::::' ;!' .!!!!!!!!!!!!!!'`!!!!!!!!!!!;.
; `::';!> ::' ;<!.;!!!!!!!''''!!!!' <!! !!!!!!!!!!!>
\end{filecontents*}
\newsavebox{\asciiart}
\newcommand{\duck}{\raisebox{.8\height}{\resizebox{1.5ex}{!}{\usebox{\asciiart}}}}
\begin{document}
\begin{lrbox}{\asciiart}
\begin{varwidth}{\maxdimen}
\noindent\lstinputlisting[basicstyle=\ttfamily]{duck.txt}
\end{varwidth}
\end{lrbox}%
We love to see \duck{} duck.
\end{document}
放大后发现...
答案2
每个位置对应一个像素,该位置上的字符模拟灰色。
对于固定短语,重复,如“生日快乐”,最好使用 lua 代码或正则表达式将 ascii 映射到每个位置的阴影。
平均能量损失
\documentclass{article}
\usepackage{fontspec}
\setmonofont{FreeMono}[Scale=0.5]
\newcommand\art{\fontsize{8pt}{0.4ex}\selectfont%
:~~~~~s~~~~~::::,,,,,,,,,,,,::,:~~~~~sssssssssss~~:::~::::,,,,,,,,,:::~ss\%\%\%s\%\%\%\%\%\%\%\%\%\%\%\%\%\%s~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~~sssss~~~~::::::,,,,,,,,,,,:,,:~~~~~sssssssss~~~:::,,,,,,,,,,,,,:::::::~~sss\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~ssssss~~~~::::::,,,,,,,,,,,,,,:~~~~~sssss~~~~:,:::::,,,,,,,,,,,,::::::::::::~~sss\%\%\%\%\%\%\%\%\%s~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~sssssss~~~:::,,,,,,,,,,,,,,,,,:~~~~~~~~~~::::,::::::,,,,,,,,,,,,,:::::::::::::::~~~~~ssssss~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
sssssss~~~~:::,,,,,,,,,,,,,,,,,::::::~~::~~~::::::::,,,,,,,,,,,,,,::::::::::::::::::::::::~~::,,,::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~ssssss~~~~:::,,,,,,,,,,,,,,,,,::::::::~~~::::::::::,,,,,,,,,,,,,,::::::::::::::::::::::::,::,:::::~~~~~~::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~sssss~~~~~:::,,,,,,,,,,,,,,,,,:::::~:~~::::::::::::,,,,,,,,,,,,,,:,:::::::::::::::::,,::,,,:::::~~sssssssss~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~sss~~~~~~::::,,,,,,,,,,,,,,,,,,,::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::~~~~sss\%\%\%\%\%\%\%\%\%s~::,,,,,,,,,,,,,,,,,,,,,,,,,,
~~~~~~~~::::::,,,,,,,,,,,,,,,,,,:::,,:::::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::M\llap{X}M\llap{X}M\llap{X}sssss\%\%\%\%\%\%\%\%\%\%\%s~::,,,,,,,,,,,,,,,,,,,,,,,,,
:::::::::::::,,,,,,,,,,,,,,,,,,:::,,,:,:::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::O\llap{/}M\llap{X}M\llap{X}M\llap{X}ss\%\%\%sss\%\%\%\%\%\%s\%\%\%\%s:,,,,,,,,,,,,,,,,,,,,,,,
::::::::::::,,,,,,,,,,,,,,,,,,,:::,,::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}sss\%sssss\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~,,,,,,,,,,,,,,,,,,,,
:::::::::::,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~~~~sssO\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}:,,,,,,,,,,,,,,,,,,
::::::::::,,,,,,,,,,,,,,,,,,,,,::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},,,::~O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},,,,,,,,,,,,,,,,,
,,:::::,,,,,,,,,,,,,,,,,,,,,::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}:,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%M\llap{X}\%\%O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}:::,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}\%\%s\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~~:::,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%\%O\llap{/}sss\%\%O\llap{/}O\llap{/}\%\%\%\%O\llap{/}~~~~~~::,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\%O\llap{/}O\llap{/}\%s\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}\%s\%ssssss\%\%\%\%\%\%\%:::~~~~~~::,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\%\%O\llap{/}ss\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}ssssss~sssss\%\%~~~~~~~~~~~~::,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}M\llap{X}\%ssM\llap{X}M\llap{X}O\llap{/}O\llap{/}~,,,,,,,,,77M\llap{X}~\%M\llap{X}M\llap{X}M\llap{X}:,,:,,,,,,,,,,,,,,,,,,,,,\%O\llap{/}O\llap{/}sss\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}sss~ss~~sss\%s~sssss~~~~~~~~::,,,,
:,,,,,,,,......,,,,,,,,,,,,,,,,,,,,,,O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}7M\llap{X}M\llap{X}M\llap{X}M\llap{X}77M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}:,:,,,,:,,,,,,,,,,,,,,,\%O\llap{/}O\llap{/}\%sss\%\%\%\%\%\%\%O\llap{/}O\llap{/}M\llap{X}sssss~~~ss\%~~~ssssss~~~~~~~~::,,,
::,,,,,,,.......,,,,,,,,,,,,,,,,,,,M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}7777777M\llap{X}M\llap{X}M\llap{X}M\llap{X}7M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}M\llap{X}M\llap{X}O\llap{/}:,,:,,,::::::::::::,:~\%O\llap{/}O\llap{/}ssss\%\%\%\%\%\%\%O\llap{/}O\llap{/}ssss~~~~s\%\%\%\%\%O\llap{/}~~~~~ssssss~~::,,,
:::,,,,,,.........,,,,,,,,,,,,,,,,O\llap{/}M\llap{X}M\llap{X}M\llap{X}77777777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}sO\llap{/}~:::::::::::::::::~\%O\llap{/}O\llap{/}ssssss\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~~ssssssss\%\%O\llap{/}:::~~~~~~:::,,,,
:::,,,,,,.........,,,,,,,,,,,,,,,~O\llap{/}O\llap{/}M\llap{X}777777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}::::::::::::::~s~s\%\%ssssssssssssss\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}sssssssss\%\%O\llap{/}:::::::::,,,,,,
:::,,,,,,.........,,,,,,,,,,,,::,\%O\llap{/}M\llap{X}M\llap{X}7777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}:::::::::::~\%sss\%\%\%ss~sssssssssssss\%\%\%O\llap{/}ss\%\%\%\%\%\%\%O\llap{/}M\llap{X}M\llap{X}:::::,,,,,,,,,
:::,,,,,,......,,,,,,,,,,,,,,,::,\%O\llap{/}O\llap{/}777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%\%\%\%\%\%O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}:::,:::::\%ss\%\%\%\%sss~:~sssssssssssss\%\%\%\%\%\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}::::,,,,,,,,,,
:::,,,,,,,..,,,,,,,,,,,,,,,,,,,,:O\llap{/}M\llap{X}M\llap{X}77M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}\%\%\%s\%O\llap{/}ssO\llap{/}\%\%\%\%\%\%O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}:,:::::\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%s:::::~~~~ssssssssssss\%\%\%\%\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}M\llap{X}::::::::::,,,
:::,,,,,,,,,,,,,,,,,,,,,,,,,,,M\llap{X}77777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%ss\%O\llap{/}\%M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}:~~~~O\llap{/}~~~~:::::~:,:~:sssssss\%O\llap{/}\%\%\%O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}ssssssss~~:,,
:::,,,,,,,,,,,,,,,:,,,,,,,,:7777777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%ssssssO\llap{/}O\llap{/}\%O\llap{/}ss\%\%\%\%\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}O\llap{/}ss\%ssssss~~~~:::~~:,sssssss\%\%\%\%O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%ssss~~:,
:::,,,,,,,,,,,,::~s~~~:::O\llap{/}7777777M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%sssss\%M\llap{X}O\llap{/}s\%\%s~sss\%O\llap{/}\%ssss\%\%O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}\%ssssss~:~~~~:,,,,~,O\llap{/}\%\%\%\%\%\%\%O\llap{/}\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%\%\%\%\%ssss~
:::,,,,,,,:~sss~s~~~~~~~7777777M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%sssss\%O\llap{/}O\llap{/}O\llap{/}\%\%ss\%\%~~ss\%O\llap{/}ssss\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%ssssss:~ss~~::,,,::,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}\%O\llap{/}O\llap{/}\%sssssssssssssss
:::,,,,,,~ss~~~~~~~~~~~:s777M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%sssss\%\%O\llap{/}O\llap{/}\%O\llap{/}ss\%O\llap{/}O\llap{/}\%~~s\%ss\%sss\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%s~ssss::\%sss~~:,,,,~,,,,O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%::::::::~~~~~~::
:::,,,:ss\%\%\%\%\%ss~sssss~:O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%sssss\%\%\%\%O\llap{/}\%O\llap{/}s\%\%O\llap{/}O\llap{/}O\llap{/}~~\%\%ss~sss\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%~~~~~::sssss~~:::::::::::,,,,,,~M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%::::::::::::::,,,
:::,,,:s\%\%O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}M\llap{X}\%ss\%O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}\%\%\%O\llap{/}O\llap{/}O\llap{/}\%\%\%\%ssss\%\%\%\%\%\%O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%s~\%s~\%~~~ss\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%~~~~~:~~ss~~:::~~~~~~~~::::,,,,,:O\llap{/}M\llap{X}M\llap{X}\%:,::::::::::,,,,,,,
::,,,::::~s\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}\%\%\%M\llap{X}M\llap{X}O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}\%\%\%O\llap{/}M\llap{X}sss\%\%\%O\llap{/}s\%O\llap{/}s\%\%\%\%sss\%s~s~s~ssO\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%sss~~::sss~::~~~~ssssssss~~::,,,,,,:,,,,,:::::::::::,,,,,
,:,,,:::::~~~~O\llap{/}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}\%O\llap{/}O\llap{/}\%ss\%O\llap{/}7ss\%\%\%\%s\%\%ssssssssss\%s\%~~ss\%\%\%\%O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%\%~sss~:~~s~:::~ssss\%\%\%\%\%\%\%ss~~:,,,,,,,,,,,,:::::::::::,,,,
:::,,,,::~~~~~sO\llap{/}M\llap{X}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}77M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}\%\%ss\%\%O\llap{/}7ss\%\%sss\%ss\%\%\%\%O\llap{/}\%\%O\llap{/}O\llap{/}s~~~s\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%~~~ss::ss~::::~ss\%sss\%s\%\%sss~~::::::,,,,,,,,:::::::::::,,,
::::,,,,,,,,::::~s\%O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}777M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%ss\%\%\%O\llap{/}M\llap{X}ss\%sss\%ssssssss\%sss~ss\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%,:~s~:~s\%~:::~\%\%\%\%sssssss~~~::~~~~~~~~:::,,,,:::::::::,,,,
:::::,,,,,,,,,,,,,,,::~s\%O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}O\llap{/}M\llap{X}M\llap{X}O\llap{/}\%\%sss~\%\%\%\%M\llap{X}\%\%O\llap{/}ss\%ssssssssss~~sss\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X},,:~::sss~::~\%O\llap{/}O\llap{/}\%ssss~~::::,,::~~~~~~~~~~~::,::::::::::::,
,::::,,,,,,,,,,,,,,,,,,,,~O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%sss~s\%\%\%M\llap{X}M\llap{X}ss\%O\llap{/}O\llap{/}O\llap{/}\%s~~ssss\%O\llap{/}\%O\llap{/}\%\%\%O\llap{/}\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}M\llap{X}O\llap{/}M\llap{X},,::~\%\%s::s\%O\llap{/}\%ss\%\%\%~:,,,,,,,,,:::::~~~~~~~::,,,:::::::::~
,,::::,,,,,,,,,,,,,,,,,,,,:O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}O\llap{/}\%\%\%sss~sssM\llap{X}M\llap{X}M\llap{X}~\%\%\%\%O\llap{/}O\llap{/}~O\llap{/}\%\%ssssss\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},:~:~\%\%s:s\%\%\%s~ss~:,,,,,,,::::::::::::::::::,,,,::,,,,::~
,,::::,,,,,,,,,,,,,,,,,,,,,,sO\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}\%\%\%sssssssssO\llap{/}O\llap{/}s~sssssssssss\%ssss\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},,::~ss~s\%\%s~~::::,,,,,::::~~~~~:::,,,,,,:::,,,,,,,,,,,,,
,,,:::,,,,,,,,,,,,,,,,,,,,,,,:sO\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%ssssssssssO\llap{/}\%ss~sssssssssssss\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}:,::ss~~~~::::::::::,,:::~~~~~~~::,,,,,,,,,,,,,,:,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:\%\%O\llap{/}O\llap{/}O\llap{/}\%\%\%\%sssss~~sssO\llap{/}O\llap{/}ssss~sssss\%\%\%\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}M\llap{X}O\llap{/}O\llap{/}~::~ss::,,:::::::::::::::::~~~~~::,,,,,,,,,,,,,,,,,,:,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sss\%\%\%s~~~ssssssss\%sssssss\%\%\%\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~~::~~:,:::~~~~s~~~::,,,,,:::::::::::,,,,,,,,,,,,,,,,::::,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\%ssss~ssssssssss~ssssss\%sss\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X},,~~:::,,::::::~~:,,,,,,,,,:::::::::::,,,,,,,,,,,,,,,,,,,::
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~\%\%\%sssssssssssss~ssss\%sss\%\%\%\%\%O\llap{/}O\llap{/}M\llap{X}O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}O\llap{/}M\llap{X}O\llap{/}M\llap{X}\%~:~~:,,,:::,,,,,::~~:,,,,,,,:::::::::::,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}\%\%\%ssssssssssss~~s\%\%\%\%\%\%\%\%\%\%O\llap{/}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}M\llap{X}~sO\llap{/}::~~~~,:~:,,,,,,,,,,:~:,,,,,,::::::::::,,,,,,,,,,,,,,,,,,...,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%sssssssss~~~~~~\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}~~s~sss\%ssss~~~~~~:~:,,,,,,,,,,,,,,,,,,,,,:::::::::,,,,,,,,,,,,,,,,,,,.,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%\%\%\%s\%ssssssssssss~~:~~~~~:~::::::~~~~~~s,,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%\%\%\%\%\%\%\%\%\%sssss\%sss:::~~~~~~sssssss~~~~s~,,,,,,,,,,,,,::~~~~~::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%\%s:,::~~sssssss~~~~~~~ss:::::,,,,,,,::~ssss~~~:::,,,,,,,,::::::,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}\%O\llap{/}O\llap{/}\%\%\%\%\%O\llap{/}O\llap{/}\%\%\%\%sss,,::~~~~~~~~~~s~~~~s::::~~::,,,::~~sssss~~~::::,,,,:::~~~~~:,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%~sss~~~:::::~~~~ss~~~~~::::~~~::,,::~~~~~~ss~~~:::::,:::~~~sss~:,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}:::~::~s~:~~~~s~~~~~~~~~::::::::,,:~~ss~~s~sss~~~::::::::::~~~::,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~\%O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}\%,s:,,s~:~s\%s::~~~~~~~~~:,:::::::::::~sssssssssss~~~::~:::::::::,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/}O\llap{/},,,,,,,,,~ssssss::~~::~~~,,,,,:::::::~~sssssss~~~~~~~~~~~~~~:::::,,,,,,,,,,,,,..
,,,,,,,,:::::~~~:::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~O\llap{/}\%\%\%::,,,,,,,,,::s~ssssss:::::s,,,,:::::::::::~~~~~~:::::::::::::::~~~::,,,,,,,,,,,,,,,
,,,,,,,::~~~~~sssss~~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:,,,,:,:~s~~s~~sss~:~:::~~::::::~~~~:::::::,,,,:::::::::::~~~:::,,,,,,,:~~:,,.
,,,,,,:::~~ssssssssssss~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::~:::~:::~~~~:~~~~~~~:::~~~~~::::::,:::::::::::::~~~~::,,....,,:~~~~:
}
\begin{document}
\ttfamily
\art
\end{document}
答案3
改编并稍微扩展了 izabera 2014 年在 texSE 上的回答(如何从特定文本组成图像?),如果我们从便携式灰度图(.pgm)文件开始
原始解决方案代码产生此
使用扩展命令,可以将整个图片变为阴影文本
或仅较轻的部分
或仅较暗的部分
在文本形状方面,对于普通的单色文本,可以填充较浅的阴影区域
或较暗的阴影区域
平均能量损失
%Adapting and slightly extending izabera's answer on texSE from 2014:
%https://tex.stackexchange.com/questions/183447/how-compose-an-image-from-a-specific-text
\documentclass{article}
\usepackage{luacode}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fontspec}
\setmonofont{FreeMono}
\directlua {require "asciiart3"}
\newcommand\bwasciitextshape[5]{\directlua{bwasciitextshape("#1",#2,#3,#4,[[#5]])}}
\newcommand\bwasciitextshade[5]{\directlua{bwasciitextshade("#1",#2,#3,#4,[[#5]])}}
\newcommand\bwascii[1]{\directlua{bwascii("#1")}}
\newcommand\colorascii[1]{\directlua{colorascii("#1")}}
\newcommand\bwframe[1]{\vspace*{\fill}\bwascii{#1}\vspace*{\fill}\newpage}
\newcommand\colorframe[1]{\vspace*{\fill}\colorascii{#1}\vspace*{\fill}\newpage}
\begin{document}
\begin{tabular}{c}
\fbox{\includegraphics{flower1.png}}\\
Bermuda buttercup \\
Wikipedia: ``flower'' \\
\end{tabular}
\hfill
$\mapsto$
\hfill
\begin{tabular}{c}
\fbox{\includegraphics{flower1gs.png}}\\
grayscale \\
\\
\end{tabular}
\newpage
\ttfamily\frenchspacing
\newlength{\correctem}\settowidth{\correctem}{M}%to set the size of the minipage
\newlength{\correctex}\settowidth{\correctex}{x}%to set the line height
\pagestyle{empty}\centering
%----------------------------------------------------
%\bwasciitextshade{flower1.pgm}{1}{0}{256}{A flower, ...}
%\bwasciitextshade{A} {B}{C}{D} {E}
% A = image filename
% portable gray map format (.pgm)
% create .pgm fle with, e.g., ImageMagick:
%magick convert -compress none -resize 50% flower1.png flower1.pgm
% B = line spacing scaling factor
% 1: aspect-ratio of image kept, but text is close together
% <1: squash image vertically (e.g., 0.8)
% >1: stretch image vertically (e.g., 1.2): easier to read text
% C = from-value, grayscale
% integer, 0 (darkest) to 255 (lightest)
% D = to-value, grayscale
% integer, 0 (darkest) to 255 (lightest)
% E = text
%----------------------------------------------------
ascii art: \textbackslash bwasciitextshade: full picture filled with matching multi-shaded text\par(text from Wikipedia: "flower")
\fbox{%
\bwasciitextshade{flower1.pgm}{1}{0}{256}{A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) resulting from cross pollination or allow selfing (fusion of sperm and egg from the same flower) when self-pollination occurs. }
}
\newpage
ascii art: \textbackslash bwasciitextshade: light-shaded shapes filled with matching multi-shaded text
\fbox{%
\bwasciitextshade{flower1.pgm}{1}{170}{256}{A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) resulting from cross pollination or allow selfing (fusion of sperm and egg from the same flower) when self-pollination occurs. }
}
\newpage
ascii art: \textbackslash bwasciitextshade: dark-shaded shapes filled with matching multi-shaded text
\fbox{%
\bwasciitextshade{flower1.pgm}{1}{0}{170}{A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) resulting from cross pollination or allow selfing (fusion of sperm and egg from the same flower) when self-pollination occurs. }
}
\newpage
ascii art: \textbackslash bwasciitextshape: light-shaded shapes filled with normal-shade text
\fbox{%
\bwasciitextshape{flower1.pgm}{1}{170}{256}{A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) resulting from cross pollination or allow selfing (fusion of sperm and egg from the same flower) when self-pollination occurs. }
}
\newpage
ascii art: \textbackslash bwasciitextshape: dark-shaded shapes filled with normal-shade text
\fbox{%
\bwasciitextshape{flower1.pgm}{1}{0}{170}{A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to facilitate reproduction, usually by providing a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) resulting from cross pollination or allow selfing (fusion of sperm and egg from the same flower) when self-pollination occurs. }
}
\newpage
ascii art: \textbackslash bwascii: 256-grayscale mapped to 8-scale text (\$, B, Q, Y, v, \textasciitilde, ., \textvisiblespace)
\fbox{%
\bwascii{flower1.pgm}
}
\end{document}
asciiart3.lua
colorascii = function ( picture )
-- read a picture in .ppm format
local file = io.open(picture, "r")
if file==nil then
tex.sprint("file not found")
return
end
local arr = {}
for line in file:lines() do
if line:sub(1,1)~="#" then--if line starts with # don't insert it
table.insert(arr,line);
end
end
file:close()
if arr[1]~="P3" then
tex.sprint("i don't like this file")
--TODO: implement moar ways to detect if the file is corrupt
return
end
local sizes = {}
for i in string.gmatch(arr[2],"%d+") do
table.insert(sizes,i)
end
local xsize = tonumber(sizes[1])
local ysize = tonumber(sizes[2])
table.remove(arr,1)--remove "P3"
table.remove(arr,1)--remove sizes
table.remove(arr,1)--remove maxval and assume no value is bigger than 255
colors = ""
for k,v in pairs(arr) do
colors = colors..v.." "
end
colors = string.gsub(colors, " +", " ")
--now all our picture is in a single string
rgb = {}
for i in string.gmatch(colors,"%d+ %d+ %d+") do
temp = {}
for j in string.gmatch(i, "%d+") do
table.insert(temp,j)
end
table.insert(rgb, temp)
end
tex.sprint("\\noindent\\resizebox{\\textwidth}{!}{")
tex.sprint("\\noindent\\begin{minipage}{"..xsize.."\\correctem}\\setlength\\baselineskip{1\\correctex}\\setlength\\lineskip{0pt}\\setlength\\prevdepth{0pt}")
for i = 1,#rgb do
tex.sprint("\\definecolor{mycolor}{RGB}{"..rgb[i][1]..","..rgb[i][2]..","..rgb[i][3].."}\\textcolor{mycolor}x\\hspace{0pt}")
end
tex.sprint("\\end{minipage}}")
end
valchar = function (val)--takes an integer from 0 to 255 and returns a character
val = tonumber(val)
valuetable = {"\\$","B","Q","Y","v","~","."," "}--return darker characters for darker values
return valuetable[math.floor(val/32)+1]
end
bwasciitextshade = function ( picture, bsl, thresholda, thresholdb, mystring )
local file = io.open(picture, "r")
if file==nil then
tex.sprint("file not found")
return
end
local arr = {}
for line in file:lines() do
if line:sub(1,1)~="#" then
table.insert(arr,line);
end
end
file:close()
if arr[1]~="P2" then
tex.sprint("i don't like this file")
return
end
local sizes = {}
for i in string.gmatch(arr[2],"%d+") do
table.insert(sizes,i)
end
local xsize = tonumber(sizes[1])
local ysize = tonumber(sizes[2])
table.remove(arr,1)
table.remove(arr,1)
table.remove(arr,1)
greys = ""
for k,v in pairs(arr) do
greys = greys..v.." "
end
greys = string.gsub(greys, " +", " ")
value = {}
for i in string.gmatch(greys,"%d+") do
table.insert(value, i)
end
tex.sprint("\\noindent\\resizebox{\\textwidth}{!}{")
tex.sprint("\\noindent\\begin{minipage}{"..xsize.."\\correctem}\\setlength\\baselineskip{"..bsl.."\\correctex}\\setlength\\lineskip{0pt}\\setlength\\prevdepth{0pt}\\leavevmode")
local letterarray = {}
local targetStr = mystring
-- Looping through strings require gmatch.
for c in string.gmatch(targetStr, ".") do
table.insert(letterarray, c)
end
local i = 0
local itemcount = 1
for i = 1,#value do
if (tonumber(value[i]) > tonumber(thresholda)) and
(tonumber(value[i]) < tonumber(thresholdb)) then
-- tex.sprint("\\smash{"..valchar(value[i]).."}\\hspace{0pt}")
if #letterarray > 0 then
tex.sprint("\\color[gray]{"..(tonumber(value[i])/255).."}\\smash{"..letterarray[itemcount].."}\\hspace{0pt}")
itemcount=itemcount+1
if itemcount == #letterarray + 1 then
itemcount = 1
end
end
else
tex.sprint("\\smash{".."\\ ".."}\\hspace{0pt}")
end
end
tex.sprint("\\end{minipage}}")
end
--
bwasciitextshape = function ( picture, bsl, thresholda, thresholdb, mystring )
local file = io.open(picture, "r")
if file==nil then
tex.sprint("file not found")
return
end
local arr = {}
for line in file:lines() do
if line:sub(1,1)~="#" then
table.insert(arr,line);
end
end
file:close()
if arr[1]~="P2" then
tex.sprint("i don't like this file")
return
end
local sizes = {}
for i in string.gmatch(arr[2],"%d+") do
table.insert(sizes,i)
end
local xsize = tonumber(sizes[1])
local ysize = tonumber(sizes[2])
table.remove(arr,1)
table.remove(arr,1)
table.remove(arr,1)
greys = ""
for k,v in pairs(arr) do
greys = greys..v.." "
end
greys = string.gsub(greys, " +", " ")
value = {}
for i in string.gmatch(greys,"%d+") do
table.insert(value, i)
end
tex.sprint("\\noindent\\resizebox{\\textwidth}{!}{")
tex.sprint("\\noindent\\begin{minipage}{"..xsize.."\\correctem}\\setlength\\baselineskip{"..bsl.."\\correctex}\\setlength\\lineskip{0pt}\\setlength\\prevdepth{0pt}\\leavevmode")
local letterarray = {}
local targetStr = mystring
-- Looping through strings require gmatch.
for c in string.gmatch(targetStr, ".") do
table.insert(letterarray, c)
end
local i = 0
local itemcount = 1
for i = 1,#value do
if (tonumber(value[i]) > tonumber(thresholda)) and
(tonumber(value[i]) < tonumber(thresholdb)) then
-- tex.sprint("\\smash{"..valchar(value[i]).."}\\hspace{0pt}")
if #letterarray > 0 then
tex.sprint("\\smash{"..letterarray[itemcount].."}\\hspace{0pt}")
itemcount=itemcount+1
if itemcount == #letterarray + 1 then
itemcount = 1
end
end
else
tex.sprint("\\smash{".."\\ ".."}\\hspace{0pt}")
end
end
tex.sprint("\\end{minipage}}")
end
--
bwascii = function ( picture )
local file = io.open(picture, "r")
if file==nil then
tex.sprint("file not found")
return
end
local arr = {}
for line in file:lines() do
if line:sub(1,1)~="#" then
table.insert(arr,line);
end
end
file:close()
if arr[1]~="P2" then
tex.sprint("i don't like this file")
return
end
local sizes = {}
for i in string.gmatch(arr[2],"%d+") do
table.insert(sizes,i)
end
local xsize = tonumber(sizes[1])
local ysize = tonumber(sizes[2])
table.remove(arr,1)
table.remove(arr,1)
table.remove(arr,1)
greys = ""
for k,v in pairs(arr) do
greys = greys..v.." "
end
greys = string.gsub(greys, " +", " ")
value = {}
for i in string.gmatch(greys,"%d+") do
table.insert(value, i)
end
tex.sprint("\\noindent\\resizebox{\\textwidth}{!}{")
tex.sprint("\\noindent\\begin{minipage}{"..xsize.."\\correctem}\\setlength\\baselineskip{1\\correctex}\\setlength\\lineskip{0pt}\\setlength\\prevdepth{0pt}\\leavevmode")
local i = 0
for i = 1,#value do
tex.sprint("\\smash{"..valchar(value[i]).."}\\hspace{0pt}")
end
tex.sprint("\\end{minipage}}")
end
对于鸦科动物来说,精细的细节需要高分辨率,并且非常浅的阴影文本将更难辨别(尽管所有文本都可以复制)。
(原版画来自《塞尔伯恩自然史》,通过 SciHi 博客)
平均能量损失
\documentclass{article}
\usepackage{luacode}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fontspec}
\setmonofont{FreeMono}
\directlua {require "asciiart3"}
\newcommand\bwasciitextshape[5]{\directlua{bwasciitextshape("#1",#2,#3,#4,[[#5]])}}
\newcommand\bwasciitextshade[5]{\directlua{bwasciitextshade("#1",#2,#3,#4,[[#5]])}}
\newcommand\bwascii[1]{\directlua{bwascii("#1")}}
\newcommand\colorascii[1]{\directlua{colorascii("#1")}}
\newcommand\bwframe[1]{\vspace*{\fill}\bwascii{#1}\vspace*{\fill}\newpage}
\newcommand\colorframe[1]{\vspace*{\fill}\colorascii{#1}\vspace*{\fill}\newpage}
\begin{document}
\ttfamily\frenchspacing
\newlength{\correctem}\settowidth{\correctem}{M}%to set the size of the minipage
\newlength{\correctex}\settowidth{\correctex}{x}%to set the line height
\pagestyle{empty}\centering
%\colorframe{lenna_128x128.ppm}
%\colorframe{lisa_150x224.ppm}
%\colorframe{knuth_192x227.ppm}
%\bwframe{einstein_150x206.pgm}
%----------------------------------------------------
%\bwasciitextshade{flower1.pgm}{1}{0}{256}{A flower, ...}
%\bwasciitextshade{A} {B}{C}{D} {E}
% A = image filename
% portable gray map format (.pgm)
% create .pgm fle with, e.g., ImageMagick:
%magick convert -compress none -resize 50% flower1.png flower1.pgm
% B = line spacing scaling factor
% 1: aspect-ratio of image kept, but text is close together
% <1: squash image vertically (e.g., 0.8)
% >1: stretch image vertically (e.g., 1.2): easier to read text
% C = from-value, grayscale
% integer, 0 (darkest) to 255 (lightest)
% D = to-value, grayscale
% integer, 0 (darkest) to 255 (lightest)
% E = text
%----------------------------------------------------
\bwasciitextshade{raveneap.pgm}{1}{5}{240}{Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
"'Tis some visitor," I muttered, "tapping at my chamber door--
Only this and nothing more."
Ah, distinctly I remember it was in the bleak December;
And each separate dying ember wrought its ghost upon the floor.
Eagerly I wished the morrow;--vainly I had sought to borrow
From my books surcease of sorrow--sorrow for the lost Lenore--
For the rare and radiant maiden whom the angels name Lenore--
Nameless here for evermore.
}
\end{document}
答案4
国际妇女节
120 黑底白字 ASCII 艺术
:~~~~~=~~~~~::::,,,,,,,,,,,,::,:~~~~~===========~~:::~::::,,,,,,,,,:::~==+++=++++++++++++++=~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~~=====~~~~::::::,,,,,,,,,,,:,,:~~~~~=========~~~:::,,,,,,,,,,,,,:::::::~~===+++++++++++++++~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~======~~~~::::::,,,,,,,,,,,,,,:~~~~~=====~~~~:,:::::,,,,,,,,,,,,::::::::::::~~===+++++++++=~:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~=======~~~:::,,,,,,,,,,,,,,,,,:~~~~~~~~~~::::,::::::,,,,,,,,,,,,,:::::::::::::::~~~~~======~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
=======~~~~:::,,,,,,,,,,,,,,,,,::::::~~::~~~::::::::,,,,,,,,,,,,,,::::::::::::::::::::::::~~::,,,::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~======~~~~:::,,,,,,,,,,,,,,,,,::::::::~~~::::::::::,,,,,,,,,,,,,,::::::::::::::::::::::::,::,:::::~~~~~~::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~=====~~~~~:::,,,,,,,,,,,,,,,,,:::::~:~~::::::::::::,,,,,,,,,,,,,,:,:::::::::::::::::,,::,,,:::::~~=========~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,
~===~~~~~~::::,,,,,,,,,,,,,,,,,,,::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::~~~~===+++++++++=~::,,,,,,,,,,,,,,,,,,,,,,,,,,
~~~~~~~~::::::,,,,,,,,,,,,,,,,,,:::,,:::::::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::III=====+++++++++++=~::,,,,,,,,,,,,,,,,,,,,,,,,,
:::::::::::::,,,,,,,,,,,,,,,,,,:::,,,:,:::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::?III==+++===++++++=++++=:,,,,,,,,,,,,,,,,,,,,,,,
::::::::::::,,,,,,,,,,,,,,,,,,,:::,,::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,??III===+=====+????????????~,,,,,,,,,,,,,,,,,,,,
:::::::::::,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,I???????~~~~===????????????????:,,,,,,,,,,,,,,,,,,
::::::::::,,,,,,,,,,,,,,,,,,,,,::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:???????,,,::~?????????I?II??????,,,,,,,,,,,,,,,,,
,,:::::,,,,,,,,,,,,,,,,,,,,,::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,????????,,,,,??????III????II??????:,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:???????++I++?IIIIII?++?????I??????:::,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,?????+??????IIIIII??++=++?????????~~:::,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,???++++???????I???++?===++??++++?~~~~~~::,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,+??+=+++??????I??+=+======+++++++:::~~~~~~::,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,++?==+++++???????======~=====++~~~~~~~~~~~~::,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,?I+==II??~,,,,,,,,,77I~+III:,,:,,,,,,,,,,,,,,,,,,,,,+??===++++++?????===~==~~===+=~=====~~~~~~~~::,,,,
:,,,,,,,,......,,,,,,,,,,,,,,,,,,,,,,?IIIIIIIII7IIII77IIIIIIIIIIIII:,:,,,,:,,,,,,,,,,,,,,,+??+===+++++++??I=====~~~==+~~~======~~~~~~~~::,,,
::,,,,,,,.......,,,,,,,,,,,,,,,,,,,IIIII7777777IIII7IIII?IIIIIII??II?:,,:,,,::::::::::::,:~+??====+++++++??====~~~~=+++++?~~~~~======~~::,,,
:::,,,,,,.........,,,,,,,,,,,,,,,,?III77777777IIIIIIIIII?IIIIII????III=?~:::::::::::::::::~+??======++++++?????~~========++?:::~~~~~~:::,,,,
:::,,,,,,.........,,,,,,,,,,,,,,,~??I777777IIIIIIIII???????IIII??????IIII?::::::::::::::~=~=++==============+????=========++?:::::::::,,,,,,
:::,,,,,,.........,,,,,,,,,,,,::,+?II7777IIIII?III?????+++???IIIIII???IIIII:::::::::::~+===+++==~=============+++?==+++++++?II:::::,,,,,,,,,
:::,,,,,,......,,,,,,,,,,,,,,,::,+??777IIIII??III????++++++++++??III???IIII?:::,:::::+==++++===~:~=============++++++++++++???::::,,,,,,,,,,
:::,,,,,,,..,,,,,,,,,,,,,,,,,,,,:?II77III??????+?+++=+?==?++++++??I???????III:,:::::+????+=:::::~~~~============+++++++++++???I::::::::::,,,
:::,,,,,,,,,,,,,,,,,,,,,,,,,,,I77777IIIII??????++++==+?+I??????????????????III:~~~~?~~~~:::::~:,:~:=======+?+++?+???????+++????========~~:,,
:::,,,,,,,,,,,,,,,:,,,,,,,,:7777777IIIII????++======??+?==+++++++++++????????II?==+======~~~~:::~~:,=======++++??+?????I+++????+++++====~~:,
:::,,,,,,,,,,,,::~=~~~:::?7777777IIII??????++=====+I?=++=~===+?+====++??I?????IIIIII+======~:~~~~:,,,,~,?+++++++?++????II+????+++++++++====~
:::,,,,,,,:~===~=~~~~~~~7777777III?I?????+++=====+???++==++~~==+?====++?????????????+======:~==~~::,,,::,,???????III???II+??+===============
:::,,,,,,~==~~~~~~~~~~~:=777IIII?????????++=====++??+?==+??+~~=+==+===++??????????++=~====::+===~~:,,,,~,,,,??I???IIII?I???+::::::::~~~~~~::
:::,,,:==+++++==~=====~:?IIIIII??+++????++=====++++?+?=++???~~++==~===++??????????++~~~~~::=====~~:::::::::::,,,,,,~III???+::::::::::::::,,,
:::,,,:=++???+??I+==+??+????IIII?+++???++++====++++++?+????+=~+=~+~~~==+??????????++~~~~~:~~==~~:::~~~~~~~~::::,,,,,:?II+:,::::::::::,,,,,,,
::,,,::::~=+????III+++II??IIIIIII??+???+++?I===+++?=+?=++++===+=~=~=~==??????????++===~~::===~::~~~~========~~::,,,,,,:,,,,,:::::::::::,,,,,
,:,,,:::::~~~~?I?IIII??I?IIIIIIIIII?+??+==+?7==++++=++==========+=+~~==++++??I???++~===~:~~=~:::~====+++++++==~~:,,,,,,,,,,,,:::::::::::,,,,
:::,,,,::~~~~~=?II?IIII?I77IIIIIIIII??++==++?7==++===+==++++?++??=~~~=++++++?????+~~~==::==~::::~==+===+=++===~~::::::,,,,,,,,:::::::::::,,,
::::,,,,,,,,::::~=+???II777IIIIIIIII???+==+++?I==+===+========+===~==+++++++?????+,:~=~:~=+~:::~++++=======~~~::~~~~~~~~:::,,,,:::::::::,,,,
:::::,,,,,,,,,,,,,,,::~=+??IIIII??II?++===~++++I++?==+==========~~===+++++???????I,,:~::===~::~+??+====~~::::,,::~~~~~~~~~~~::,::::::::::::,
,::::,,,,,,,,,,,,,,,,,,,,~???????????++===~=+++II==+???+=~~====+?+?+++?+++?????II?I,,::~++=::=+?+==+++~:,,,,,,,,,:::::~~~~~~~::,,,:::::::::~
,,::::,,,,,,,,,,,,,,,,,,,,:??????I???+++===~===III~++++??~?++======+++++++?????????,:~:~++=:=+++=~==~:,,,,,,,::::::::::::::::::,,,,::,,,,::~
,,::::,,,,,,,,,,,,,,,,,,,,,,=??????I?+++=========??=~===========+====++++++????????,,::~==~=++=~~::::,,,,,::::~~~~~:::,,,,,,:::,,,,,,,,,,,,,
,,,:::,,,,,,,,,,,,,,,,,,,,,,,:=???????+++==========?+==~=============+++++???????I?:,::==~~~~::::::::::,,:::~~~~~~~::,,,,,,,,,,,,,,:,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:++???++++=====~~===??====~=====++++++++????????I??~::~==::,,:::::::::::::::::~~~~~::,,,,,,,,,,,,,,,,,,:,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,===+++=~~~========+=======+++++???????????????~~::~~:,:::~~~~=~~~::,,,,,:::::::::::,,,,,,,,,,,,,,,,::::,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,+====~==========~======+===++?????????+??IIII,,~~:::,,::::::~~:,,,,,,,,,:::::::::::,,,,,,,,,,,,,,,,,,,::
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~+++=============~====+===+++++??I?IIIII?I?I+~:~~:,,,:::,,,,,::~~:,,,,,,,:::::::::::,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,??+++============~~=++++++++++?IIIIIIIII~=?::~~~~,:~:,,,,,,,,,,:~:,,,,,,::::::::::,,,,,,,,,,,,,,,,,,...,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,????++++=========~~~~~~+??????~~=~===+====~~~~~~:~:,,,,,,,,,,,,,,,,,,,,,:::::::::,,,,,,,,,,,,,,,,,,,.,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,??????++++++++=+============~~:~~~~~:~::::::~~~~~~=,,,,,,,,,,,,,,,,,,,,,:::::::,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.??????++++++++++++++=====+===:::~~~~~~=======~~~~=~,,,,,,,,,,,,,::~~~~~::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,??????????++++++++++++++++++=:,::~~=======~~~~~~~==:::::,,,,,,,::~====~~~:::,,,,,,,,::::::,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,???????????+?+??+++++??++++===,,::~~~~~~~~~~=~~~~=::::~~::,,,::~~=====~~~::::,,,,:::~~~~~:,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:?????????+???+??????????+~===~~~:::::~~~~==~~~~~::::~~~::,,::~~~~~~==~~~:::::,:::~~~===~:,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~???????++?????????????:::~::~=~:~~~~=~~~~~~~~~::::::::,,:~~==~~=~===~~~::::::::::~~~::,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~+???????????+,=:,,=~:~=+=::~~~~~~~~~:,:::::::::::~===========~~~::~:::::::::,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,???????????,,,,,,,,,~======::~~::~~~,,,,,:::::::~~=======~~~~~~~~~~~~~~:::::,,,,,,,,,,,,,..
,,,,,,,,:::::~~~:::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,~?+++::,,,,,,,,,::=~======:::::=,,,,:::::::::::~~~~~~:::::::::::::::~~~::,,,,,,,,,,,,,,,
,,,,,,,::~~~~~=====~~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:,,,,:,:~=~~=~~===~:~:::~~::::::~~~~:::::::,,,,:::::::::::~~~:::,,,,,,,:~~:,,.
,,,,,,:::~~============~~::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::~:::~:::~~~~:~~~~~~~:::~~~~~::::::,:::::::::::::~~~~::,,....,,:~~~~:
提供给生成器的源图像这里[沃纳]