summaryrefslogtreecommitdiff
path: root/simpleslides-s-Automaton.tex
blob: 1fb4e08ccbf928cdd5d1fb9f5d566a99f155c81b (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
%D \module
%D   [      file=simpleslides-s-Automaton,
%D        version=2010-08-10-15:28:22+0200,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module --- Automaton Style,
%D         author=Philipp Gesang,
%D           date=\currentdate,
%D      copyright={Philipp Gesang}]
%C
%C Copyright 2007 Aditya Mahajan and Thomas A. Schmitz
%C This file may be distributed under the GNU General Public License v. 2.0.
%C Modified 2010 by Philipp Gesang

%D Providing presentation Backgrounds according to Conway's Game of Life.
%D Initially based on the BigNumber theme by A. Mahajan and Th. Schmitz. (Many,
%D many thanks!)

\writestatus{simpleslides}{loading Theme Automata}

\startmodule[simpleslides-s-Automaton]

\setupmodule[mode=,file=,rule=,extendxy=] % using defaults from lua config

\ctxlua{environment.loadluafile( "automata" )}
\ctxlua{mplife.slides = true}

\unprotect

%D First, we change the page layout to have more space all around

\setuplayout [              width=fit,
                           margin=2cm,
                           height=fit,
	             leftmargindistance=.2cm,
	            rightmargindistance=.2cm,
                           header=18mm, 
                   headerdistance=.3cm,
                           footer=0cm, 
                   footerdistance=0mm,
                         topspace=.5cm, 
                        backspace=1.9cm,
                         location=singlesided]

\setuplayout [simpleslides:layout:horizontal][header=14mm]
\setuplayout [simpleslides:layout:vertical]  [header=0mm]
\setuplayout [simpleslides:layout:title]     

\setuplayer[simpleslides:layer:slidetitle]
    [width=\paperwidth,
    height=\paperheight,x=20mm]

%D Next we a generic frames, which will be used by other macros to
%D get a consistent look and feel.

\defineframed[simpleslides:framed:small]
             [ frame=off,
              offset=0pt,
               width=1.7cm,
               align=middle]

\setupcombinations[distance=2.5em]

%D These macros are used for placing figures/pictures:

\define\NormalHeight        {\textheight}
\define\NormalWidth         {.46\textwidth}
\define\PictureFrameHeight  {\textheight}
\define\PictureFrameWidth   {.46\textwidth}

%D This module has two color schemes, a blue one and a red one.

\startsetups simpleslides:setups:blue
\definecolor [simpleslides:contrastcolor]      [r=0.7,g=0.7,b=0.9]
%\definecolor [simpleslides:backgroundcolor]	   [s=1]
\definecolor [simpleslides:backgroundoutside]  [r=0.9,g=0.9,b=0.95]
\definecolor [simpleslides:backgroundscreen]	 [s=.975]
\definecolor [simpleslides:textcolor]          [s=0]
\stopsetups

\startsetups simpleslides:setups:red
\definecolor [simpleslides:contrastcolor]     [r=0.4]
%\definecolor [simpleslides:backgroundcolor]	  [s=.95]
\definecolor [simpleslides:backgroundoutside] [r=0.5,g=0.2,b=0.2]
\definecolor [simpleslides:backgroundscreen]	[s=.4]
\definecolor [simpleslides:textcolor]         [s=1]
\stopsetups

%D Now we choose the scheme that the user asked for

\doifsetupselse
    {simpleslides:setups:\moduleparameter{simpleslides}{color}}
    {\setups{simpleslides:setups:\moduleparameter{simpleslides}{color}}}
    {\setups{simpleslides:setups:blue}}

\setupcolors[textcolor={simpleslides:textcolor}]

%D Set the initial snapshot (from file) and the rule, if given.

\doifsomethingelse{\moduleparameter{simpleslides}{mode}}
{\ctxlua{
mplife.setup.current.mode = "\luaescapestring{\moduleparameter{simpleslides}{mode}}"
if mplife.setup.current.mode == "life" then
    mplife.successive = mplife.gol_successive
else
    environment.loadluafile("eca")
    mplife.successive = mplife.eca_successive
end}}
{\ctxlua{mplife.successive = mplife.gol_successive}}

%D The number of dead cells to add left and right / before and after
%D the initial frame.

\doifsomething{\moduleparameter{simpleslides}{extendxy}}{\ctxlua
    {mplife.setup.current.extendx = tonumber("\luaescapestring{\moduleparameter{simpleslides}{extendxy}}")
     mplife.setup.current.extendy = tonumber("\luaescapestring{\moduleparameter{simpleslides}{extendxy}}") }}

\doifsomething{\moduleparameter{simpleslides}{extendx}}{\ctxlua
    {mplife.setup.current.extendx = tonumber("\luaescapestring{\moduleparameter{simpleslides}{extendx}}") }}

\doifsomething{\moduleparameter{simpleslides}{extendy}}{\ctxlua
    {mplife.setup.current.extendy = tonumber("\luaescapestring{\moduleparameter{simpleslides}{extendy}}") }}

\doifsomething{\moduleparameter{simpleslides}{file}}{\ctxlua{
mplife.setup.current.file = "\luaescapestring{\moduleparameter{simpleslides}{file}}"
}}

\startluacode
if mplife.setup.current.mode == "life" then
    mplife.setup.current.init = gol.parse_file(mplife.setup.current.file)
    mplife.setup.current.last = mplife.setup.current.init
else
    mplife.setup.current.init = eca.parse_file(mplife.setup.current.file)
    mplife.setup.current.framesize = math.floor(mplife.setup.current.aspect * mplife.setup.current.init:len())
end
\stopluacode

\doifsomething{\moduleparameter{simpleslides}{rule}}{\ctxlua{
if mplife.setup.current.mode == "life" then
    mplife.setup.current.rule = gol.parse_rule("\luaescapestring{\moduleparameter{simpleslides}{rule}}") 
else
    mplife.setup.current.rule = eca.gen_rule(tonumber("\luaescapestring{\moduleparameter{simpleslides}{rule}}")) 
end
}}

%D We also use \METAPOST\ to draw the horizontal and vertical page backgrounds.
%D Backgrounds will be of solid color, the ornament gets the transparency.
                       
\startuniqueMPgraphic{simpleslides:MP:horizontal} 
StartPage ;
fill Page withcolor \MPcolor{simpleslides:backgroundoutside} ;
fill Field[Text][Text] enlarged 0.2cm
     withcolor \MPcolor{simpleslides:backgroundscreen} ;
StopPage ;
\stopuniqueMPgraphic 

\startuniqueMPgraphic{simpleslides:MP:vertical}
StartPage ;
fill Page withcolor \MPcolor{simpleslides:backgroundoutside} ;

z1 = urcorner Field[Text][Text] shifted (.2cm,0) ;
z2 = lrcorner Field[Text][Text] shifted (.2cm,-.2cm) ;
z3 = z1 shifted (-8.05cm,0) ;
z4 = (x3,y2) ;

save Main ;
path Main ;
Main := z1 -- z2 -- z4 -- z3 --cycle ;

fill Main withcolor \MPcolor{simpleslides:backgroundscreen} ;
StopPage ;
\stopuniqueMPgraphic


%D We define these backgrounds as overlays:

\defineoverlay 
  [simpleslides:background:horizontal] 
  [\useMPgraphic{simpleslides:MP:horizontal}] 

\defineoverlay 
  [simpleslides:background:vertical] 
  [\useMPgraphic{simpleslides:MP:vertical}] 

\defineoverlay 
  [simpleslides:background:title] 
  [\useMPgraphic{simpleslides:MP:horizontal}] 

\defineoverlay 
  [simpleslides:background:ornament] 
  [\ctxlua{mplife.successive()}] 

%D The slide title is placed on the top of the text area. The layer takes care
%D of the positioning.

\setupSlideTitle
   [\c!after=,
    \c!alternative=layer,
    \c!width=\textwidth,
    \c!height=2.5cm,
    \c!command=\doSlideTitle]


%D Squares are used as the first level of itemizations 

\definesymbol[1][$\square$]
\setupitemize[1][inmargin]
%\setupitemize[each][joinedup,unpacked]

\protect
\stopmodule

\endinput