\startenvironment environment

% Bug in context? Zonder de ../ kunnen componenten de files niet vinden
\usepath[{environment,../environment}]

\setupexternalfigures[directory={images,../images}]

% \definemode[afloop][yes]
% \definemode[draft][yes]
\definemode[zwartwit][yes]

\environment bib
\environment font
\environment headers
\environment notation
\environment paper
\environment pdf
\environment tikz

\mainlanguage[en]

\setupindenting[yes, medium]
%\setupwhitespace[medium]

\definefloat[algorithm][algorithms]

\defineframed[author][frame=off, location=middle, align={middle, nothypenated}, offset=5pt, width=0.33\hsize]

\definestartstop[abstract]
  [before={\blank[.5cm]\midaligned{\bf Abstract}\startnarrower[2*middle]\noindent},
   after={\stopnarrower\blank[big]}]

\def\basedon[#1]{\vfill\noindent
This chapter is based on the following publication:

\noindent\cite[entry][#1]}

\definedescription[description]
  [headstyle=bold, alternative=serried, width=fit, indenting=yes]
\definedescription[contribution]
  [headstyle=bold, alternative=serried, width=fit, indenting=no, after={\blank[2*big]}]
\definedescription[step]
  [headstyle=bold, alternative=serried, width=fit, indenting=yes, text={Step }]

% The black dot is missing from Euler?
\setupitemize[each][2,joinedup,nowhite,autointro][indentnext=no]
% For more whitespace between items
\defineitemgroup[bigitemize]
\setupitemgroup[bigitemize][each][2,autointro][indentnext=no]

% Standaard \colon had niet veel ruimte
\define\colon{{\,{:}\,\,}}
\define[1]\defn{\emph{#1}}

\define[1]\todo{\color[red]{\ss todo: \bf #1}}
\define[1]\label{\todo{\tt \\label #1}}

\define\referencesifcomponent{\doifnotmode{everything}{\startsubject[title={References}]\switchtobodyfont[9pt]\placelistofpublications\stopsubject}}

\doifnotmode{everything}
{\setupheadertexts[{\sc {\getmarking[chapter]}}][\pagenumber][\pagenumber][{\sc Chapter {\getmarking[chapternumber]}}]}


\usemodule[algorithmic]
\setupalgorithmic[align=middle,numbercolor=darkgray] % center line numbers
\setupalgorithmic[before={\startframedtext[width=0.85\textwidth,offset=none,frame=off]},after={\stopframedtext}] % To enable linenumbers in a float


\def\href#1{\useURL[#1][{#1}]{\tt\goto{\url[#1]}[url(#1)]}}


\definelayer[Logo]
  [x=\paperwidth, y=0mm, location={left, bottom}, hoffset=1mm]

\startsetups LogoSetup
\getrandomnumber \n {1} {10}
\setlayer[Logo]{
%\clip[width=1cm, height=1cm, hoffset=1.25cm, voffset=1.25cm]
%{\scale[factor=100]{\rotate[rotation=-20, frame=off, width=1cm, height=1cm, background=color, backgroundcolor=gray, foregroundcolor=white]{\n}}}

\clip[width=1cm, height=1cm, hoffset=1.5cm, voffset=.2cm]
{\framed[height=1.4cm, frame=off, align=middle, offset=0cm, background=color, backgroundcolor=gray, foregroundcolor=white]{
\getrandomnumber \n {0} {14}
\dorecurse{\n}{.} \dorecurse{6}{\pagenumber\,\, } \blank[-1ex]
\getrandomnumber \n {0} {14}
\dorecurse{\n}{.} \dorecurse{6}{\pagenumber\,\, } \blank[-1ex]
\getrandomnumber \n {0} {14}
\dorecurse{\n}{.} \dorecurse{6}{\pagenumber\,\, } \blank[-1ex]
\getrandomnumber \n {0} {14}
\dorecurse{\n}{.} \dorecurse{6}{\pagenumber\,\, } \blank[-1ex]
}}
}
\stopsetups

% \setupbackgrounds[page][setups=LogoSetup, background=Logo]


% Debugging
%\enabletrackers[references.references, visualizers.justification]
%\showmakeup
%\showlayout
%\showboxes
%\showframe
%\setupparagraphnumbering[state=start,style=italic,distance=0pt]
%\showbodyfont


\stopenvironment
