From 2e2ea4b49f9f3101b4e09b77cd33fefc93c9c3cf Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 15 Aug 2010 01:39:09 +0200 Subject: drawing Wolfram automata (inefficient) --- simpleslides-s-Automaton.tex | 48 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'simpleslides-s-Automaton.tex') diff --git a/simpleslides-s-Automaton.tex b/simpleslides-s-Automaton.tex index c1e3181..1fb4e08 100644 --- a/simpleslides-s-Automaton.tex +++ b/simpleslides-s-Automaton.tex @@ -19,9 +19,9 @@ \startmodule[simpleslides-s-Automaton] -\setupmodule[file=,rule=,extendxy=] % using defaults from lua config +\setupmodule[mode=,file=,rule=,extendxy=] % using defaults from lua config -\ctxlua{environment.loadluafile( "mplife" )} +\ctxlua{environment.loadluafile( "automata" )} \ctxlua{mplife.slides = true} \unprotect @@ -94,7 +94,21 @@ \setupcolors[textcolor={simpleslides:textcolor}] -%D Set the initial Game of Life snapshot (from file) and the rule, if given. +%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}}") @@ -106,13 +120,27 @@ \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}}" - mplife.setup.current.init = gol.parse_file(mplife.setup.current.file) - mplife.setup.current.last = mplife.setup.current.init }} - -\doifsomething{\moduleparameter{simpleslides}{rule}}{\ctxlua - {mplife.setup.current.rule = gol.parse_rule("\luaescapestring{\moduleparameter{simpleslides}{rule}}") }} +\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. -- cgit v1.2.3