-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmemoize-tikz.tex
41 lines (37 loc) · 979 Bytes
/
memoize-tikz.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% Command handler for tikz:
\makeatletter % todo: this can't be here, if it's for plain TeX as well
% \tikz <animation spec> [<options>] {<picture code>}
% or
% \tikz <animation spec> [<options>] <picture code>;
%
% <animation spec> = :key={value}, ...
\def\mmz@tikz{%
\mmz@temptoks={}%
\mmz@tikz@anim
}
\def\mmz@tikz@anim{%
\pgfutil@ifnextchar[{\mmz@tikz@opt}{%
\pgfutil@ifnextchar:{\mmz@tikz@anim@a}{%
\mmz@tikz@code}}%]
}%
\def\mmz@tikz@anim@a#1=#2{%
\apptotoks\mmz@temptoks{#1={#2}}%
\mmz@tikz@anim
}%
\def\mmz@tikz@opt[#1]{%
\apptotoks\mmz@temptoks{[#1]}%
\mmz@tikz@code
}
\def\mmz@tikz@code{%
\pgfutil@ifnextchar\bgroup\mmz@tikz@braced\mmz@tikz@single
}
\def\mmz@tikz@braced#1{\apptotoks\mmz@temptoks{{#1}}\mmz@tikz@done}
\def\mmz@tikz@single#1;{\apptotoks\mmz@temptoks{#1;}\mmz@tikz@done}
\def\mmz@tikz@done{%
\expandafter\MemoizeWrapper\expandafter{%
\expandafter\tikz\the\mmz@temptoks
}%
}
\memoizeset{
handler=\tikz\mmz@tikz,
}