diff options
22 files changed, 283 insertions, 96 deletions
diff --git a/examples/automatarc-eca.lua b/examples/automatarc-eca.lua new file mode 100644 index 0000000..a56833e --- /dev/null +++ b/examples/automatarc-eca.lua @@ -0,0 +1,48 @@ +if not mplife then return 1 end + +mplife.setup.rc = {} + +do + local c = {} + + c.file = "initial-eca/w40r.eca" + c.init = eca.parse_file(c.file) + c.rule = eca.gen_rule(110) + + c.clip = "left" + + c.aspect = 3/4 -- default for S6 slide format + + c.pensize = .1 + c.color = { r = .6, g = .6, b = .8 } + c.opacity = 1/3 + c.fade = true + c.gestalt = "unitsquare" -- try "unitcircle" + + c.firstframe = 1 + c.frames = 5 + + c.preamble = [[ +\setupcolors[state=start] +\setupbackgrounds[state=start] +\setuppapersize[S6][S6] + +\setuppagenumbering[state=stop,location=] + +\defineoverlay[back][\ctxlua{mplife.successive()}] + +\setupbackgrounds [page] [background=back] +]] + c.before_frame = [[ +\startMPcode +pickup pencircle xyscaled (.25*]] .. c.pensize .. [[pt, ]] .. c.pensize .. [[pt) rotated 45; +]] + c.after_frame = [[ +currentpicture := currentpicture xysized (\the\paperwidth, \the\paperheight); +\stopMPcode +]] + + mplife.setup.rc = c +end + +return mplife.setup.rc diff --git a/automatarc.lua b/examples/automatarc-gol.lua index 506b7f5..09d2476 100644 --- a/automatarc.lua +++ b/examples/automatarc-gol.lua @@ -5,18 +5,17 @@ mplife.setup.rc = {} do local c = {} - --c.file = "examples/10x10_glider.gol" - --c.file = "examples/gliders.gol" - c.file = "examples/ggun.gol" - --c.file = "examples/sships.gol" + --c.file = "initial-gol/10x10_glider.gol" + --c.file = "initial-gol/gliders.gol" + --c.file = "initial-gol/ggun.gol" + c.file = "initial-gol/sships.gol" c.rule = gol.parse_rule("B3/S23") -- default Conway --c.init = gol.parse_file(c.file) - c.last = c.init -- for successive mode + c.last = c.init -- for successive mode as used in slides - c.aspect = 3/4 + c.aspect = 3/4 -- S6 and similar - c.extendx = 0 - c.extendy = 0 + c.extendxy = 0 c.pensize = .1 c.color = { r = .6, g = .6, b = .8 } diff --git a/examples/elementary.tex b/examples/elementary.tex new file mode 100644 index 0000000..79b2097 --- /dev/null +++ b/examples/elementary.tex @@ -0,0 +1,18 @@ +\usemodule + [simpleslides] + [style=Automaton, + file=initial-eca/w40r.eca, + rule=110, + clip=left, % [left|right|both] + mode=eca, + color=blue,] + +%\ctxlua{dofile "automatarc-eca.lua"} +\starttext + +\dorecurse{10}{ +\SlideTitle{Frame Number \recurselevel} +\input hawking +} + +\stoptext diff --git a/examples/game-of-life.tex b/examples/game-of-life.tex new file mode 100644 index 0000000..182bb67 --- /dev/null +++ b/examples/game-of-life.tex @@ -0,0 +1,19 @@ +\usemodule + [simpleslides] + [style=Automaton, + file=initial-gol/sships.gol, + %file=initial-gol/oscillator_p11.rle, + rule=B3.S23, + mode=life, + %extendxy=10, + color=red,] + +%\ctxlua{dofile "automatarc-gol.lua"} +\starttext + +\dorecurse{10}{ +\SlideTitle{Frame Number \recurselevel} +\input dawkins +} + +\stoptext diff --git a/examples/initial-eca/w20m.eca b/examples/initial-eca/w20m.eca new file mode 100644 index 0000000..7657dcf --- /dev/null +++ b/examples/initial-eca/w20m.eca @@ -0,0 +1 @@ +00000000001000000000 diff --git a/examples/initial-eca/w40l.eca b/examples/initial-eca/w40l.eca new file mode 100644 index 0000000..33fce42 --- /dev/null +++ b/examples/initial-eca/w40l.eca @@ -0,0 +1 @@ +1000000000000000000000000000000000000000 diff --git a/examples/initial-eca/w40r.eca b/examples/initial-eca/w40r.eca new file mode 100644 index 0000000..9fb004f --- /dev/null +++ b/examples/initial-eca/w40r.eca @@ -0,0 +1 @@ +0000000000000000000000000000000000000001 diff --git a/examples/initial-eca/w50m.eca b/examples/initial-eca/w50m.eca new file mode 100644 index 0000000..ed2438d --- /dev/null +++ b/examples/initial-eca/w50m.eca @@ -0,0 +1 @@ +00000000000000000000000010000000000000000000000000 diff --git a/examples/initial-eca/w60r.eca b/examples/initial-eca/w60r.eca new file mode 100644 index 0000000..2d27410 --- /dev/null +++ b/examples/initial-eca/w60r.eca @@ -0,0 +1 @@ +000000000000000000000000000000000000000000000000000000000001 diff --git a/examples/10x10_glider.gol b/examples/initial-gol/10x10_glider.gol index 2c7875c..2c7875c 100644 --- a/examples/10x10_glider.gol +++ b/examples/initial-gol/10x10_glider.gol diff --git a/examples/ggun.gol b/examples/initial-gol/ggun.gol index 4855d59..4855d59 100644 --- a/examples/ggun.gol +++ b/examples/initial-gol/ggun.gol diff --git a/examples/glider_gen-p55.gol b/examples/initial-gol/glider_gen-p55.gol index 739992a..739992a 100644 --- a/examples/glider_gen-p55.gol +++ b/examples/initial-gol/glider_gen-p55.gol diff --git a/examples/gliders.gol b/examples/initial-gol/gliders.gol index 190e50f..190e50f 100644 --- a/examples/gliders.gol +++ b/examples/initial-gol/gliders.gol diff --git a/examples/initial-gol/oscillator_p11.rle b/examples/initial-gol/oscillator_p11.rle new file mode 100644 index 0000000..e36e5b2 --- /dev/null +++ b/examples/initial-gol/oscillator_p11.rle @@ -0,0 +1,12 @@ +#C P11-2009-05-30.rle +#C by N.Beluchenko +x=23, y=23 +7b2o$7bobo$8bo2$15b2o$15b2o$4b2o$4b2o2b3o10b2o$8bo4b3o4bobo$8bobo4bo5bo$13b +obo2$7bobo$bo5bo4bobo$obo4b3o4bo$2o10b3o2b2o$17b2o$6b2o$6b2o2$14bo$13bobo$14b +2o! +x=23, y=23, color=(0,0,0), alpha=48 +7b2o$7bobo$8b2o$7b2o$7b3o5b2o$5b6o3b4o$4b7ob6o$4b7ob8ob2o$5b16obo$6b5ob7ob +2o$6b4o3b5o$8bo5bo$5b5o3b4o$b2ob7ob5o$ob16o$2ob8ob7o$5b6ob7o$5b4o3b6o$6b2o5b +3o$14b2o$13b2o$13bobo$14b2o! +CB 2,2,2,2 + diff --git a/examples/initial-gol/sships.gol b/examples/initial-gol/sships.gol new file mode 100644 index 0000000..c5a615c --- /dev/null +++ b/examples/initial-gol/sships.gol @@ -0,0 +1,54 @@ +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000010010000000000000000000000000000000000000000000000000000000000000000000000 +0000000001000000000000000000000000000000000000000000000000000000000000000000000 +0000010001000000000000000000000000000000000000000000000000000000000000000000000 +0000001111000000000000000000000000000000000000000000000000000000000000000000000 +0101000000000000000000000000000000000000000000000000000000000000000000000000000 +0000100000000000000000000000000000000000000000000000000000000000000000000000000 +0000100000000000000000000000000000000000000000000000000000000000000000000000000 +0100100000000000000000000000000000000000000000000000000000000000000000000000000 +0011100000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -1,17 +1,13 @@ -- -------------------------------------------------------------------------------- -- FILE: run.lua --- USAGE: ./run.lua +-- USAGE: texlua run.lua -- DESCRIPTION: Game of Life CLI frontend --- OPTIONS: --- --- REQUIREMENTS: --- --- BUGS: --- --- NOTES: --- +-- REQUIREMENTS: texlua or similar interpreter +-- BUGS: dozens, if lucky -- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com> --- COMPANY: -- VERSION: 1.0 -- CREATED: 05/08/10 13:09:52 CEST --- REVISION: --- -------------------------------------------------------------------------------- -- diff --git a/eca.lua b/module/tex/context/third/simpleslides/automata/automata-eca.lua index 6c49e8d..95d1f71 100644 --- a/eca.lua +++ b/module/tex/context/third/simpleslides/automata/automata-eca.lua @@ -1,21 +1,16 @@ -- -------------------------------------------------------------------------------- --- FILE: eca.lua --- USAGE: ./eca.lua +-- FILE: automata-eca.lua -- DESCRIPTION: drawing elementary cellular automata --- OPTIONS: --- --- REQUIREMENTS: --- --- BUGS: --- --- NOTES: --- +-- REQUIREMENTS: ConTeXt MkIV with Simple Slides module +-- BUGS: uncountable -- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com> --- COMPANY: -- VERSION: 1.0 -- CREATED: 14/08/10 19:43:35 CEST --- REVISION: --- -------------------------------------------------------------------------------- -- -require "life" +environment.loadluafile( "automata-life" ) local help = gol.helpers @@ -61,7 +56,7 @@ end function eca.next_line(from, rule) local new = "" from = "0"..from.."0" -- assume dead borders - --from = string.format("0%s0", from) + --from = string.format("0%s0", from) -- too slow local cell = C(S"01") local cells= Ct(cell * #(cell * cell)) / function (t) @@ -72,28 +67,32 @@ function eca.next_line(from, rule) return new end +function eca.stripcells (str, dir, cnt) + if dir == "left" then + return str:sub( cnt ) + elseif dir == "right" then + return str:sub( 0, str:len() - cnt ) + else -- assume ambilateral clipping + return str:sub( cnt, str:len() - cnt ) + end +end + function eca.gen_frame(from, lines, rule) - local new = { [1] = from } local cnt = 1 - local tmp + local c = mplife.setup.current + + local new = { [1] = eca.stripcells(from, c.clip, c.diff ) } + repeat - --print(cnt) - tmp = eca.next_line(from, rule) - table.insert( new, tmp ) - from = tmp + from = eca.next_line(from, rule) + table.insert( new, eca.stripcells(from, c.clip, c.diff) ) cnt = cnt + 1 until cnt == lines - --for i,j in ipairs(new) do - --print (string.format("%3s >> %s",i,j)) - --end - return eca.next_line(tmp, rule), new + return eca.next_line(from, rule), new end function eca.successive (current) - --if not current then print("NOPE")return 1 end - --local current = current or {} - local thisframe current.from, thisframe = eca.gen_frame(current.from, current.framesize, current.rule) if not context then -- cli invocation diff --git a/life.lua b/module/tex/context/third/simpleslides/automata/automata-life.lua index af0cb6e..01fc97b 100644 --- a/life.lua +++ b/module/tex/context/third/simpleslides/automata/automata-life.lua @@ -1,17 +1,12 @@ -- -------------------------------------------------------------------------------- --- FILE: life.lua --- USAGE: ./life.lua +-- FILE: automata-life.lua -- DESCRIPTION: Conway's Game of Life? --- OPTIONS: --- --- REQUIREMENTS: --- --- BUGS: --- --- NOTES: --- +-- REQUIREMENTS: ConTeXt MkIV / Simple Slides module +-- BUGS: almost infinite but not quite -- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com> --- COMPANY: -- VERSION: 1.0 -- CREATED: 05/08/10 12:03:11 CEST --- REVISION: --- -------------------------------------------------------------------------------- -- @@ -183,8 +178,8 @@ gol.formats[".cell"] = function (fname) end gol.formats[".rle"] = function (fname) - local parser = require "parsers/rle" - return parser(fname) + environment.loadluafile( "parser-rle" ) + return gol.rleparser(fname) end function gol.extend_area(rows) @@ -224,7 +219,6 @@ function gol.extend_area(rows) end end - --for i,j in ipairs(tmp) do print(i,j) end return tmp end @@ -233,7 +227,6 @@ function gol.parse_file (fname) local p_fn = (1-p_suf)^1 * C(p_suf) local suffix = p_fn:match(fname) or ".gol" -- assume .gol format as default - print("HERE!!!!!!!!!"..suffix) local tmp = gol.formats[suffix] ( fname ) if mplife and mplife.setup.current and ( mplife.setup.current.extendx > 0 or diff --git a/automata.lua b/module/tex/context/third/simpleslides/automata/automata-main.lua index a765f2c..c7d1435 100644 --- a/automata.lua +++ b/module/tex/context/third/simpleslides/automata/automata-main.lua @@ -1,17 +1,17 @@ -- -------------------------------------------------------------------------------- --- FILE: automata.lua --- USAGE: use with ConTeXt MkIV --- DESCRIPTION: Metapost output for Conway's Game of Life +-- FILE: automata-main.lua +-- USAGE: use with ConTeXt MkIV and the Simple Slides Module +-- DESCRIPTION: Metapost output for Conway's Game of Life and Elementary +-- Cellular Automata -- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com> --- COMPANY: -- VERSION: 1.0 -- CREATED: 06/08/10 12:28:35 CEST -------------------------------------------------------------------------------- -- ---require "run" -require "life" +environment.loadluafile( "automata-life" ) +environment.loadluafile( "automata-eca" ) local C, Cs, Ct, P, R, S, match = lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.match @@ -20,10 +20,10 @@ mplife = {} mplife.setup = mplife.setup or {} if context then - environment.loadluafile "automatarc-global" - environment.loadluafile "automatarc" + environment.loadluafile( "automatarc-global" ) + environment.loadluafile( "automatarc-eca" ) else -- assuming we're staying in pwd - require "automatarc" + require ( "automatarc-eca" ) end mplife.setup.current = {} @@ -32,7 +32,6 @@ mplife.setup.current = {} do local g, r, c = mplife.setup.global, mplife.setup.rc, mplife.setup.current for key,_ in pairs(g) do - --print(key, ">>>", tostring(r[key]) .. " or " .. tostring(g[key])) c[key] = r[key] or g[key] -- prefer local settings end mplife.setup.current = c @@ -77,7 +76,6 @@ function mplife.draw_grid(grid, settings) local n = 0 while grid[#grid-n] ~= nil do - local row = grid[#grid-n] local pos = 1 @@ -122,9 +120,6 @@ border = (0,0)--(%s,0)--(%s,%s)--(0,%s)--cycle; setbounds currentpicture to boundingbox border ; ]], max.x, max.x, max.y, max.y) ---fill border withcolor transparent (1,.75, white) ; ---fill border withcolor transparent (1,.3,1white) ; - --print("Pic\n", pat) mplife.runcode(pat) return true end @@ -144,7 +139,6 @@ function mplife.checker(n) end if n % 2 == 0 then cnt = cnt + 1 end -- needed for even column numbers end - --print (squares) return squares end diff --git a/automatarc-global.lua b/module/tex/context/third/simpleslides/automata/automatarc-global.lua index 95225d9..22f8fd9 100644 --- a/automatarc-global.lua +++ b/module/tex/context/third/simpleslides/automata/automatarc-global.lua @@ -16,26 +16,28 @@ mplife.setup.global = {} do local c = {} - c.file = "examples/sships.gol" - c.rule = gol.parse_rule("B3/S23") -- default Conway - --c.init = gol.parse_file(c.file) - c.last = c.init -- for successive mode +-- c.file = "sships.gol" +-- c.init = gol.parse_file(c.file) +-- c.last = c.init -- for successive mode - c.aspect = 3/4 -- actually 1/(x/y), for eca mode + c.rule = gol.parse_rule("B3/S23") -- default Conway - c.extendx = 0 - c.extendy = 0 + c.aspect = 3/4 -- actually 1/(x/y), for eca mode - c.pensize = .1 - c.color = { r = .6, g = .6, b = .8 } - c.opacity = 1/3 - c.fade = true - c.gestalt = "unitsquare" -- try "unitcircle" + c.extendxy = 0 + c.extendx = 0 + c.extendy = 0 + + c.pensize = .1 + c.color = { r = .6, g = .6, b = .8 } + c.opacity = 1/3 + c.fade = true + c.gestalt = "unitsquare" -- try "unitcircle" c.firstframe = 1 - c.frames = 5 + c.frames = 5 - c.preamble = [[ + c.preamble = [[ \setupcolors[state=start] \setupbackgrounds[state=start] \setuppapersize[S6][S6] @@ -46,11 +48,11 @@ do \setupbackgrounds [page] [background=back] ]] - c.before_frame = [[ + c.before_frame = [[ \startMPcode pickup pencircle xyscaled (.25*]] .. c.pensize .. [[pt, ]] .. c.pensize .. [[pt) rotated 45; ]] - c.after_frame = [[ + c.after_frame = [[ currentpicture := currentpicture xysized (\the\paperwidth, \the\paperheight); \stopMPcode ]] diff --git a/parsers/rle.lua b/module/tex/context/third/simpleslides/automata/parsers/parser-rle.lua index cd10493..e51eeea 100644 --- a/parsers/rle.lua +++ b/module/tex/context/third/simpleslides/automata/parsers/parser-rle.lua @@ -17,7 +17,7 @@ local exclam = P"!" local equals = P"=" local dollar = P"$" local state = S"bo" ---local sign = S("+-")^0 -- support negative grid values? not yet +--local sign = S("+-")^0 -- support negative grid values? not yet, if ever… local comment = hashmark * (1-eol)^0 * eol @@ -49,7 +49,6 @@ local cell = C(num^0) * C(state) / function (n, c) end if n_of_t (tonumber(n), c) == nil then - print("OVER HERE", n_row,n, c) end rows[n_row] = rows[n_row] .. n_of_t (tonumber(n), c) end @@ -76,7 +75,7 @@ end local p_rle = comment^0 * geometry * line * (dollar * line)^0 * whitespace * exclam -local function parser(fname) +function gol.rleparser(fname) local file = assert(io.open(fname, "r"), "Not a file: " .. fname) local data = file:read("*all") file:close() @@ -87,9 +86,10 @@ local function parser(fname) end return rows else + if context then + context.writestatus("simpleslides", "There were problems loading file "..fname..".") + end return false end end -return parser - diff --git a/simpleslides-s-Automaton.tex b/module/tex/context/third/simpleslides/simpleslides-s-Automaton.tex index 1fb4e08..0fa089a 100644 --- a/simpleslides-s-Automaton.tex +++ b/module/tex/context/third/simpleslides/simpleslides-s-Automaton.tex @@ -19,9 +19,15 @@ \startmodule[simpleslides-s-Automaton] -\setupmodule[mode=,file=,rule=,extendxy=] % using defaults from lua config - -\ctxlua{environment.loadluafile( "automata" )} +\setupmodule[ + mode=, + file=, + rule=, + extendxy=, + clip=, +] % using defaults from lua config + +\ctxlua{environment.loadluafile( "automata-main" )} \ctxlua{mplife.slides = true} \unprotect @@ -102,7 +108,7 @@ mplife.setup.current.mode = "\luaescapestring{\moduleparameter{simpleslides}{mod if mplife.setup.current.mode == "life" then mplife.successive = mplife.gol_successive else - environment.loadluafile("eca") + environment.loadluafile("automata-eca") mplife.successive = mplife.eca_successive end}} {\ctxlua{mplife.successive = mplife.gol_successive}} @@ -124,13 +130,55 @@ end}} mplife.setup.current.file = "\luaescapestring{\moduleparameter{simpleslides}{file}}" }} +\doifsomething{\moduleparameter{simpleslides}{clip}}{\ctxlua + {mplife.setup.current.clip = "\luaescapestring{\moduleparameter{simpleslides}{clip}}" }} + \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()) +do + local c = mplife.setup.current + if c.mode == "life" then + c.init = gol.parse_file(c.file) + c.last = c.init + else + c.init = eca.parse_file(c.file) + c.framesize = math.floor(c.aspect * c.init:len()) + c.pages = structure.counters.record("realpage")["last"] + -- Clipping is essential to cope with left/right propagation of + -- patterns. E.g. with rule 158 the total propagation at iteration + -- n is itself n to the left and n to the right. Whereas rule 102 + -- (a Sierpiński fractal generator) protrudes only to the left at + -- a rate of n. + -- Frames cannot be simply cut off at the borders with adjacient + -- cells treated as “dead” because it would distort the pattern. + -- Therefore, frames are generated as complete sections which are + -- clipped to the desired size, as specified by the initial row. + -- To determine whether to clip your pattern to the left, right, + -- or in both directions, check the propagation at + -- string.format("http://mathworld.wolfram.com/Rule%s.html", rule) + -- or consult Wolfram's “A New Kind of Science” but beware not to + -- buy everything he claims… + if c.clip then + c.xneeded = c.pages * c.framesize + if c.clip == "both" then -- Assume initial pattern is centered. + c.diff = c.xneeded - math.ceil(c.init:len()/2) + else + c.diff = c.xneeded - c.init:len() + end + if c.diff > 0 then + local affix = "" + for i=1, c.diff, 1 do + affix = affix .. "0" + end + if c.clip == "left" or c.clip == "both" then + c.init = affix .. c.init + end + if c.clip == "right" or c.clip == "both" then + c.init = c.init .. affix + end + end + end + end + mplife.setup.current = c end \stopluacode |