%D \module
%D   [      file=simpleslides-s-SideToc,
%D        version=2010.02.09,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module --- SideToc style,
%D         author=Aditya Mahajan and Thomas A. Schmitz,
%D           date=\currentdate,
%D      copyright={Aditya Mahajan and Thomas A. Schmitz}]
%C
%C Copyright 2010 Aditya Mahajan and Thomas A. Schmitz
%C This file may be distributed under the GNU General Public License v. 2.0.

%D This file provides the \quotation{SideToc} style for the presentation
%D module. It is loaded at runtime. 

\writestatus{simpleslides}{loading Fuzzy Frame style}

\startmodule[simpleslides-s-FuzzyFrame]

\unprotect

%D We create different layouts for the title page, horizontal, and vertical
%D slides.

\setuplayout  [simpleslides:layout:vertical]
	      [leftmargin=0cm,
	      rightmargin=0cm,
              header=0.1cm, 
	      headerdistance=1.7cm,
              header=0cm, 
	      headerdistance=0cm,
              footer=0cm, 
              topspace=1cm, 
              backspace=1cm,
              bottomspace=0cm,
              bottom=0pt,
              location=middle]

\setuplayout  [simpleslides:layout:horizontal]
	      [width=fit,
              leftmargin=0cm,
	      rightmargin=0cm,
              height=fit, 
              header=0.1cm, 
	      headerdistance=1.7cm,
              footer=0cm, 
              topspace=1cm, 
              backspace=1cm,
              bottomspace=0cm,
              bottom=0pt,
              location=middle]

\setuplayout  [simpleslides:layout:title]
	      [width=fit,
              leftmargin=0cm,
	      rightmargin=0cm,
              height=fit, 
              header=0cm, 
	      headerdistance=0cm,
              footer=0cm, 
              topspace=1cm, 
              backspace=1cm,
              bottomspace=0cm,
              bottom=0pt,
              location=middle]

\setupcombinations[distance=0.75cm]

%D This is basically the same as the FuzzyTopic style, minus the "Topic" list;
%D I just wanted something with a randomized border and took that style as
%D template.

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

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

\setuplayer
  [simpleslides:layer:slidetitle]
  [x=1cm,y=0mm]

%D We define our color scheme
\definecolor [simpleslides:contrastcolor]     [r=0.23,g=0.31,b=0.59]
\definecolor [simpleslides:backgroundcolor]   [s=0.9]
\definecolor [simpleslides:altcontrastcolor]  [s=0.95]
\definecolor [simpleslides:textcolor]         [s=0]
\definecolor [simpleslides:itemize:color]     [simpleslides:contrastcolor]

%D We use \METAPOST to draw the background.

\startuseMPgraphic{simpleslides:MP:title}
StartPage ;
fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;
for i=1 upto 20 :
 draw Page enlarged -5pt randomized 15pt withcolor \MPcolor{simpleslides:contrastcolor} ;
endfor ;
StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{simpleslides:MP:horizontal}
StartPage ;
pickup pencircle scaled .5pt ;
fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;
for i=1 upto 20 :
 draw Page enlarged -5pt randomized 15pt withcolor \MPcolor{simpleslides:contrastcolor} ;
endfor ;
z[1] = ulcorner Page shifted (1cm, -2.2cm) ;
z[2] = urcorner Page shifted (-1cm, -2.2cm) ;
path sep ; sep = z[1] -- z[2] ;
for i=1 upto 20 :
 draw sep randomized 15pt withcolor \MPcolor{simpleslides:contrastcolor} ;
endfor ;
StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{simpleslides:MP:vertical}
StartPage ;
pickup pencircle scaled .5pt ;
fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;
for i=1 upto 20 :
 draw Page enlarged -5pt randomized 15pt withcolor \MPcolor{simpleslides:contrastcolor} ;
endfor ;
z[1] = 1/2[ulcorner Page, urcorner Page] shifted (0, -8mm) ;
z[2] = 1/2[llcorner Page, lrcorner Page] shifted (0, 15mm) ;
path sep ; sep = z[1] -- z[2] ;
for i=1 upto 20 :
 draw sep randomized 15pt withcolor \MPcolor{simpleslides:contrastcolor} ;
endfor ;
StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{simpleslides:MP:ornament2}
StartPage ;
save d, s, r ; numeric d, s, r ;
d = 4mm ;
s = 0.33 * PaperWidth ;
z[1] = (0,0) shifted (s, 1.5*d) ;
z[2] = z[1] shifted (0, d) ;
save p ; path p[] ;
p[1] = z[1] -- z[2] ;
pickup pencircle scaled 0.5pt ;
r = 150*(PageNumber/NOfPages) ;
z[3] = z[1] shifted (r, -4pt) ;
for i=1 upto 150 :
 draw p[1] shifted (i*s/150, 0) randomized 2pt withcolor 
 (if i < r : \MPcolor{simpleslides:contrastcolor}
      else : \MPcolor{simpleslides:altcontrastcolor}
      fi) ;
endfor ;
StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{simpleslides:MP:ornament}
StartPage ; 
save v, s, l, r ; numeric v, s, l, r ;
save p ; path p ;
v = 0.8cm ;
s = 0.33*PaperWidth ;
z[1] = (0,0) shifted (s,v) ;
z[2] = (PaperWidth,0) shifted (-s,v) ;
l = arclength (z[1] --z[2]) ;
r = (l*PageNumber/NOfPages) ;
z[3] = z[1] shifted (-5mm, -3mm) ;
z[4] = z[1] shifted (-5mm, 3mm) ;
if PageNumber = NOfPages :
 z[5] = z[1] shifted (r+5mm,-3mm) ;
 z[6] = z[1] shifted (r+5mm,3mm) ;
else:
 z[5] = z[1] shifted (r,-3mm) ;
 z[6] = z[1] shifted (r,3mm) ;
fi ;
pickup pencircle scaled 3pt ;
p = z[1] -- z[2] ;
pickup pencircle scaled .5pt ;
 for i=1 upto 15 :
  draw p randomized 12pt withcolor \MPcolor{simpleslides:altcontrastcolor} ;
 endfor ;
picture old ; old := currentpicture ;
clip old to z[3] -- z[4] -- z[6] -- z[5] -- cycle ; 
draw old withcolor \MPcolor{simpleslides:contrastcolor} ;
StopPage ;
\stopuseMPgraphic

%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:title}] 

\defineoverlay 
  [simpleslides:background:ornament] 
  [\useMPgraphic{simpleslides:MP:ornament2}]

%D We want the title to placed in color. 

\setupTitle
  [\c!title=,
   \c!author=,
   \c!date=\currentdate,
   \c!headstyle=,
   \c!headcolor={simpleslides:contrastcolor},
   \c!align=\v!middle,
   \c!before=\vfill,
   \c!after=\vfill,
   \c!title\c!style={\switchtobodyfont[\TitleSize]},
   \c!title\c!color=simpleslides:contrastcolor,
   \c!title\c!align=\v!middle,
   \c!author\c!style=,
   \c!author\c!color={simpleslides:contrastcolor},
   \c!author\c!align=\v!middle, 
   \c!date\c!style=,
   \c!date\c!color={simpleslides:contrastcolor},
   \c!date\c!align=\v!middle,
   \c!before\c!title=,
   \c!before\c!author=,
   \c!before\c!date=,
   \c!after\c!title={\blank[1*line]},
   \c!after\c!author={\blank[2*line]},
   \c!after\c!date=]

%D We want the slide title on the top

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

%D The symbol for the first level of itemizations. 

\startuseMPgraphic{simpleslides:itemize:square}
save p ; path p[] ;
save d ; numeric d ; d := 4mm ;
p[1] := unitsquare xyscaled(d,d) ;
p[2] := ulcorner p[1] -- llcorner p[1] ;
pickup pencircle scaled (d/100) ;
for i=1 upto 15 :
 draw p[2] shifted (i*d/15, 0) randomized (d/12.5) withcolor \MPcolor{simpleslides:itemize:color} ;
endfor ;
\stopuseMPgraphic

\definesymbol[1][\useMPgraphic{simpleslides:itemize:square}]
\setupitemize[1][color=simpleslides:itemize:color]

\protect
\stopmodule

\endinput
