Last active
August 29, 2015 14:11
-
-
Save zr-tex8r/42cd63a727891276a30f to your computer and use it in GitHub Desktop.
The dancing men that are really dancing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage[papersize={12cm,3cm}, | |
noheadfoot,margin=0pt]{geometry} | |
\usepackage{color} | |
\pagecolor{white} | |
\definecolor{myred}{rgb}{0.85,0,0} | |
\definecolor{mygreen}{rgb}{0,0.45,0} | |
\usepackage{tcdancers} | |
\begin{document} | |
\centering\dancers | |
\color{myred}\normalsize | |
comEherEaToncE\par\smallskip | |
\color{mygreen}\small | |
thEdancinGmeN\par | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
# | |
my $texname = shift(@ARGV) || "sample"; | |
my $dpi = 150; | |
my $tick = 10; | |
my $nframes = 20; | |
# | |
$texname =~ s/\.tex$//; | |
my $srcname = "dancers"; | |
my $tpkname = "tcdancers"; | |
my $rsfname = "r_seed"; | |
my $xsrcname = $srcname . $$ . "rx"; | |
my $kpsewhich = "kpsewhich"; | |
my $pdflatex = "pdflatex"; | |
my $imconvert = "convert"; | |
my $srcpath; | |
{ | |
(-f "$texname.tex") or die "File '$texname.tex' not found"; | |
system("$kpsewhich $srcname.mf > $xsrcname.txt"); | |
open(my $hh, '<', "$xsrcname.txt") or die; | |
$srcpath = <$hh>; chomp($srcpath); | |
close($hh); unlink("$xsrcname.txt"); | |
($srcpath ne '') | |
or die "File '$srcname.mf' not found on TeX search path"; | |
} | |
{ | |
open(my $hi, '>', "$tpkname.sty") or die; | |
local $_ = <<'EOT'; | |
\pdfpkresolution=300 | |
\DeclareFontFamily{OT1}{dancers}{} | |
\DeclareFontShape{OT1}{dancers}{m}{n}{<->s*[12.8]%SRC%}{} | |
\def\dancers{\usefont{OT1}{dancers}{m}{n}\relax} | |
EOT | |
s/%SRC%/$xsrcname/g; | |
print $hi ($_); | |
close($hi); | |
} | |
{ | |
open(my $hi, '<', $srcpath) or die "$srcpath, a"; | |
open(my $ho, '>', "$xsrcname.mf") or die "$xsrcname.mf"; | |
print $ho ("input $rsfname;show(uniformdeviate 1);\n"); | |
while (<$hi>) { print $ho ($_); } | |
close($hi); close($ho); | |
} | |
{ | |
my $nfmt = '%0' . length($nframes) . 'd'; | |
unlink("$xsrcname.tfm"); | |
foreach (1 .. $nframes) { | |
open(my $ho, '>', "$rsfname.mf") or die; | |
printf $ho ("randomseed:=%.6f;\n", rand() * 1000); | |
close($ho); | |
my $no = sprintf($nfmt, $_); | |
unlink(glob("$xsrcname.*pk")); | |
unlink("$texname.pdf", "$texname.aux"); | |
system("$pdflatex --halt-on-error $texname"); | |
(-s "$texname.pdf") or die; | |
system("$imconvert -density $dpi $texname.pdf $xsrcname$no.png"); | |
} | |
unlink(glob("$xsrcname.*pk")); | |
unlink("$xsrcname.tfm", "$xsrcname.log"); | |
unlink("$texname.pdf", "$texname.aux", "$texname.log"); | |
} | |
{ | |
system("$imconvert -delay $tick -loop 0 $xsrcname*.png $texname.gif"); | |
unlink("$tpkname.sty", "$xsrcname.mf", "$rsfname.mf"); | |
unlink(glob("$xsrcname*.png")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place the font source file
dancers.mf
in the TeX search path (or the current directory) and run:If all go well then the output file
sample.gif
is created.