summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-08-13 10:34:36 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-08-13 10:34:36 +0200
commitfd8ab52a6e7a622a46824f2b38e8e499bd471b64 (patch)
treec739d5b4ba89251d2adf8dbc8d7b9086dc8b4fc4
parent48838d85a768ec85a7d71f2515cd55fa1765b397 (diff)
downloadautomata-backgrounds-fd8ab52a6e7a622a46824f2b38e8e499bd471b64.tar.gz
setting initial frame and rule from simpleslides paramaters.
-rw-r--r--life.lua11
-rw-r--r--mplife.lua11
-rw-r--r--simpleslides-s-Automaton.tex141
3 files changed, 57 insertions, 106 deletions
diff --git a/life.lua b/life.lua
index a760804..42a17bd 100644
--- a/life.lua
+++ b/life.lua
@@ -41,7 +41,7 @@ end
-- Modified to match left and right of one separator only.
function gol.helpers.split_once (s, sep)
local utfchar = gol.helpers.utfchar
- sep = P(sep)
+ sep = S(sep)
local left = C((1 - sep)^0)
local right = C((utfchar)^0)
local p = Ct(left * sep * right)
@@ -67,12 +67,13 @@ function gol.helpers.dead_row(len)
return row
end
--- Read rules of type "B3/S23"
+-- Read rules of type "B3[/.-]S23"
-- => “birth” of a new cell if exactly 3 adjacent cells are “alive”
-- => “staying alive” of cells with two or three adjacent “live” cells
function gol.parse_rule (raw_rule)
+ print("HERE!!>>>>>>>>>>> "..raw_rule)
local help = gol.helpers
- local b_s = help.split_once (raw_rule, "/")
+ local b_s = help.split_once (raw_rule, "/.-")
local tmp_b = help.strip(b_s[1], "B")
local tmp_s = help.strip(b_s[2], "S")
@@ -145,6 +146,10 @@ function gol.parse_file (fname)
local tmp = {} -- return an array
local len -- check for equal line length
+ if fname:sub(-4,-1) ~= ".gol" then -- check extension
+ fname = fname .. ".gol"
+ end
+
local file = assert(io.open(fname, "r"), "Not a file: " .. fname)
for line in file:lines() do
if not len then len = string.len(line) end
diff --git a/mplife.lua b/mplife.lua
index e430827..c3067ab 100644
--- a/mplife.lua
+++ b/mplife.lua
@@ -29,9 +29,10 @@ do
--c.file = c.file or "examples/10x10_glider.gol"
--c.file = c.file or "examples/gliders.gol"
- c.file = c.file or "examples/ggun.gol"
- c.rule = gol.parse_rule("B3/S23") -- default Conway
- c.init = gol.parse_file(c.file)
+ --c.file = c.file or "examples/ggun.gol"
+ c.file = c.file or "examples/sships.gol"
+ c.rule = c.rule or gol.parse_rule("B3/S23") -- default Conway
+ c.init = c.init or gol.parse_file(c.file)
c.last = c.init -- for successive mode
c.pensize = .1
@@ -127,12 +128,12 @@ function mplife.draw_grid(grid, settings)
if fade_level ~= 0 then -- skip dead cells
if fade_level == 1 then
- pat = pat .. string.format("%s %s shifted (%s,%s) withcolor transparent(1,%s,%s);\n",
+ pat = pat .. string.format("%s %s shifted (%s,%s) withcolor transparent (1,%s,%s);\n",
"draw", c.gestalt, p.x, p.y, opacity*2, settings.color)
else
opacity = opacity - (fade_level * opacity * .1)
end
- pat = pat .. string.format("%s %s scaled .9 shifted (%s+.05,%s+.05) withcolor transparent(1,%s,%s);\n",
+ pat = pat .. string.format("%s %s scaled .9 shifted (%s+.05,%s+.05) withcolor transparent (1,%s,%s);\n",
"filldraw", c.gestalt, p.x, p.y, opacity, settings.color)
end
pos = pos + 1
diff --git a/simpleslides-s-Automaton.tex b/simpleslides-s-Automaton.tex
index 4ec1d19..1b4b277 100644
--- a/simpleslides-s-Automaton.tex
+++ b/simpleslides-s-Automaton.tex
@@ -9,6 +9,7 @@
%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,
@@ -18,6 +19,8 @@
\startmodule[simpleslides-s-Automaton]
+\setupmodule[file=,rule=] % using defaults from lua config
+
\ctxlua{environment.loadluafile( "mplife" )}
\ctxlua{mplife.slides = true}
@@ -25,18 +28,20 @@
%D First, we change the page layout to have more space all around
-\setuplayout [width=fit,
- margin=2cm,
- height=fit,
- leftmargindistance=.8cm,
- rightmargindistance=0cm,
- header=18mm,
- footer=0cm,
- topspace=.8cm,
- backspace=1.9cm,
- location=singlesided]
-
-\setuplayout [simpleslides:layout:horizontal][header=18mm]
+\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]
@@ -48,8 +53,10 @@
%D get a consistent look and feel.
\defineframed[simpleslides:framed:small]
- [frame=off,offset=0pt,
- width=1.7cm,align=middle]
+ [ frame=off,
+ offset=0pt,
+ width=1.7cm,
+ align=middle]
\setupcombinations[distance=2.5em]
@@ -63,118 +70,56 @@
%D This module has two color schemes, a blue one and a red one.
\startsetups simpleslides:setups:blue
-\definecolor [simpleslides:contrastcolor] [r=0.8,g=0.8,b=0.9]
-\definecolor [simpleslides:backgroundcolor] [s=.88]
+\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=.35]
+%\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}}
+\doifsetupselse
+ {simpleslides:setups:\moduleparameter{simpleslides}{color}}
{\setups{simpleslides:setups:\moduleparameter{simpleslides}{color}}}
{\setups{simpleslides:setups:blue}}
\setupcolors[textcolor={simpleslides:textcolor}]
+%D Set the initial Game of Life snapshot (from file) and the rule, if given.
-%D The characteristic feature of this module is that the page number is drawn in
-%D big letters on the slide. First we define the font used to draw the number.
-%D The is a bit verbose since \MKII\ and \MKIV\ have different ways of loading
-%D fonts.
-
-\beginOLDTEX
-\loadmapfile[qhv-ec.map]
-\definefontsynonym [BigNumberFont] [ec-qhvb]
-\endOLDTEX
-
-\beginXETEX
-\loadmapfile[qhv-ec.map]
-\definefontsynonym [BigNumberFont] [ec-qhvb]
-\endXETEX
-
-\beginLUATEX
-\definefontsynonym [BigNumberFont] [name:texgyreherosbold]
-\endLUATEX
-
-\definefont [NumberFont] [BigNumberFont at 30pt]
-
-
-%D We use \METAPOST\ to draw backgrounds. First, we define a few helper macros
-%D to place text inside \METAPOST
-
-\definetextext[simpleslides:sometxt:left] {\TaspresentSometxtLeft}
-\definetextext[simpleslides:sometxt:right]{\TaspresentSometxtRight}
-
-\unexpanded\def\TaspresentSometxtLeft#1%
- {\getvalue{simpleslides:framed:small}
- {\color[simpleslides:contrastcolor]
- {\NumberFont #1}}}
-
-\unexpanded\def\TaspresentSometxtRight#1%
- {\getvalue{simpleslides:framed:small}
- {\color[simpleslides:backgroundcolor]
- {\NumberFont #1}}}
-
-%D Now we define a \METAPOST| graphic that draws the number. The exact
-%D dimensions have been found by trial and error.
-
-%\startuseMPgraphic{simpleslides:MP:ornament}
-%StartPage ;
-%save Left, Right ;
-%picture Left, Right ;
-
-%Left := \sometxt [simpleslides:sometxt:left]{\folio} ysized 6cm;
-%Right := \sometxt[simpleslides:sometxt:right]{\folio} ysized 6cm;
-
-%save LeftBox, RightBox ;
-%path LeftBox, RightBox ;
-
-%save split ; numeric split ;
-%split := if PageNumber < 10 : 1/2 else : 2/3 fi ;
-
-%LeftBox := llcorner Left -- split[llcorner Left, lrcorner Left]
- %-- split[ulcorner Left, urcorner Left] -- ulcorner Left --cycle ;
-
-%RightBox := lrcorner Right -- split[lrcorner Right, llcorner Right]
- %-- split[urcorner Right, ulcorner Right] -- urcorner Right --cycle ;
-
-%if PageNumber >= 10 :
-%RightBox := RightBox shifted split[lrcorner Right, llcorner Right] ;
-%fi;
-
-%clip Left to LeftBox ;
-%clip Right to RightBox ;
-
-%save corner; pair corner ;
-%corner := lrcorner Field[Text][Text] shifted (.2cm,-1cm) ; % same as x2
-
-%labeloffset := 0bp;
+%\doifsomething{\currentmoduleparameter{key}}{\setupsomething[key=\currentmoduleparameter{key}]}
-%label.ulft(Left, corner) ;
-%label.urt (Right, corner) ;
+\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 }}
-%StopPage ;
-%\stopuseMPgraphic
+\doifsomething{\moduleparameter{simpleslides}{rule}}{\ctxlua
+ {mplife.setup.current.rule = gol.parse_rule("\luaescapestring{\moduleparameter{simpleslides}{rule}}") }}
%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 transparent (1, .3, \MPcolor{simpleslides:contrastcolor}) ;
+fill Page withcolor \MPcolor{simpleslides:backgroundoutside} ;
fill Field[Text][Text] enlarged 0.2cm
- withcolor transparent (1, .3, \MPcolor{simpleslides:backgroundcolor}) ;
+ withcolor \MPcolor{simpleslides:backgroundscreen} ;
StopPage ;
\stopuniqueMPgraphic
\startuniqueMPgraphic{simpleslides:MP:vertical}
StartPage ;
-fill Page withcolor transparent (1, .3, \MPcolor{simpleslides:contrastcolor}) ;
+fill Page withcolor \MPcolor{simpleslides:backgroundoutside} ;
z1 = urcorner Field[Text][Text] shifted (.2cm,0) ;
z2 = lrcorner Field[Text][Text] shifted (.2cm,-.2cm) ;
@@ -185,7 +130,7 @@ save Main ;
path Main ;
Main := z1 -- z2 -- z4 -- z3 --cycle ;
-fill Main withcolor \MPcolor{simpleslides:backgroundcolor} ;
+fill Main withcolor \MPcolor{simpleslides:backgroundscreen} ;
StopPage ;
\stopuniqueMPgraphic