% This file is used with all three manuals and therefore is
% specified in english. This file will be adapted along the
% migration of ConTeXt from dutch to english.

\nonknuthmode

% \usemodule
%   [pictex,chemie,abr-01]

\usemodule
  [abr-01]

\unprotect

\setupcolors
  [\c!state=\v!start]

\definecolor [red]   [r=.8]      \definecolor [fullred]    [r=1]
\definecolor [green] [g=.8]      \definecolor [fullgreen]  [g=1]
\definecolor [blue]  [b=.8]      \definecolor [fullblue]   [b=1]
\definecolor [yellow][r=.8,g=.8] \definecolor [fullyellow] [r=1,g=1]
\definecolor [gray]  [s=.8]      \definecolor [fullgray]   [s=.5]

\definecolor [MainColor] [red]    \definecolor [TitleColorOne] [r=1]
\definecolor [SubColor]  [green]  \definecolor [TitleColorTwo] [g=1]

\definecolor [MainColor] [green]  \definecolor [TitleColorOne] [g=1]
\definecolor [SubColor]  [blue]   \definecolor [TitleColorTwo] [b=1]

\definecolor [MainColor] [blue]   \definecolor [TitleColorOne] [b=1]
\definecolor [SubColor]  [red]    \definecolor [TitleColorTwo] [r=1]

\definecolor [TitleColorThree] [s=.5]

\definepalet
  [en]
  [MainColor=red,
   SubColor=green,
   TitleColorOne=fullred,
   TitleColorTwo=fullgreen,
   TitleColorThree=fullgray]

\definepalet
  [en-mkiv]
  [MainColor=blue,
   SubColor=yellow,
   TitleColorOne=fullblue,
   TitleColorTwo=fullyellow,
   TitleColorThree=fullgray]

\definepalet
  [nl]
  [MainColor=green,
   SubColor=blue,
   TitleColorOne=fullgreen,
   TitleColorTwo=fullblue,
   TitleColorThree=fullgray]

\definepalet
  [de]
  [MainColor=blue,
   SubColor=red,
   TitleColorOne=fullblue,
   TitleColorTwo=fullred,
   TitleColorThree=fullgray]

\doifmodeelse {mkiv} {
    \setuppalet
      [\currentmainlanguage-mkiv] % nice trick
} {
    \setuppalet
      [\currentmainlanguage] % nice trick
}

\setupchemicalframed
  [\c!framecolor=SubColor] % \c!frame=\v!on]

\setupchemical
  [\c!rulecolor=MainColor]

\setuptables
  [\c!rulecolor=SubColor]

\setupfootnotes
  [\c!rulecolor=SubColor]

\def\dowithruledbox{\color[SubColor]}

\setupwhitespace
  [\v!big]

\setupinteraction
  [\c!page=\v!yes,
   \c!state=\v!start,
   \c!color=,
   \c!contrastcolor=]

\setupcombinations
  [\c!inbetween={\blank[\v!medium]}]

\setupalign
  [\v!bottom]

\setuplayout
  [\c!width=\v!middle,
   \c!height=\v!middle,
   \c!footer=1.5cm]

\setupnumbering
  [\c!alternative=\v!doublesided,
   \c!location=]

\setupuserpagenumber
  [\c!way=\v!by\v!part,
   \c!prefix=\v!yes,
   \c!prefixconnector=\endash]

\setupfootertexts
  [\PPCHTEX]
  [\completepagenumber]

\setuplabeltext [nl] [example=Voorbeeld~]
\setuplabeltext [en] [example=Example~]
\setuplabeltext [de] [example=Beispiel~]

\definelabel
  [example]
  [\c!text=\labeltext{example},
   \c!headstyle=\v!bold,
   \c!after={\blank\switchtobodyfont[\v!small]}]

\setupcombinedlist
  [\v!content]
  [\c!alternative=a,
   \c!interaction=\v!all]

\setuplist
  [\v!part]
  [\c!before=\blank,
   \c!after=\blank,
   \c!style=\v!bold,
   \c!pagenumber=\v!no]

\setuplist
  [\v!chapter]
  [\c!before=,
   \c!after=]

\startuseMPgraphic{page}
    numeric n ; n := OverlayWidth/10 ;
    path p, q ; p := (1,1)--(2,2)--(2,3)--(1,4)--(0,3)--(0,2)--cycle ;
    p := p scaled n ; color a, b ;
    pickup pencircle scaled (n/10) ;
    for i=-1 step 2n until OverlayWidth+n :
    for j=0 step 2n until OverlayHeight :
        q := p shifted (i if odd j : +n fi, j) ;
        a := \MPcolor{TitleColorOne} randomized(.4,.9) ;
        b := \MPcolor{TitleColorTwo} randomized(.4,.9) ;
        circular_shade(q, ceiling(uniformdeviate 4), a, b) ;
        draw q withcolor \MPcolor{TitleColorThree} ;
    endfor ;
    endfor ;
\stopuseMPgraphic

\defineoverlay[page][\useMPgraphic{page}]

\definelayout
  [titlepage]
  [\c!topspace=2cm,
   \c!bottomspace=1.25cm,
   \c!backspace=1.5cm,
   \c!width=\v!middle,
   \c!height=\v!middle,
   \c!header=0pt,
   \c!footer=0pt]

\def\titelblad#1#2#3%
  {\setuplayout[titlepage]
   \setupbackgrounds[\v!page][\c!background=page]
   \startmakeup[\v!standard]%
   \dontcomplain
   \gray \let\\=\par
   \setupalign[\v!left]
   \definedfont[SansBold at 96pt]\setupinterlinespace#1\vskip6pt
   \definedfont[SansBold at 24pt]\setupinterlinespace#2\vfill
   \definedfont[SansBold at 24pt]\setupinterlinespace#3\par
   \currentdate[\v!month,\v!year]\par
   \stopmakeup
   \setuplayout
   \setupbackgrounds[\v!page][\c!background=]}

\def\vervolgblad#1#2[#3]#4[#5]#6[#7]% % #2 gobbles space
  {\page
   \setuplayout[titlepage]
   \startmakeup[\v!standard]
   \dontcomplain
   \getvalue{\v!part}{#1}%
   \setupchemical
     [\c!bodyfont=24pt,
      \c!color=gray,
      \c!rulecolor=MainColor,
      \c!style=\bf,
      \c!rulethickness=5pt]%
   \setupalign[\v!left]
   \hfill
   \noindent \framed
     [\c!offset=6pt,
      \c!framecolor=SubColor,
      \c!rulethickness=3pt,
      \c!strut=\v!no,
      \c!background=\v!color,
      \c!backgroundcolor=gray]
     {\tfc
      \startchemical[#3]
        \chemical[#5] % [#7]
      \stopchemical}
   \par
   \bfd \setupinterlinespace \strut\labeltext{\v!part}\headnumber[\v!part]
   \par
   \bfd \setupinterlinespace \strut#1
   \vfill
   \stopmakeup
   \setuplayout
   \setupheadertexts[][#1]}

\def\koptitel#1#2%
  {\hbox to \hsize \bgroup
   \setupframed
     [\c!offset=6pt,
      \c!height=2cm,
      \c!width=6cm,
      \c!rulethickness=2pt,
      \c!framecolor=MainColor,
      \c!top=]
   \hfill
   \framed
     [\c!frame=\v!off,
      \c!align=\v!left]
     {#1}%
   \framed
     [\c!frame=\v!off,\c!leftframe=\v!on,
      \c!align=\v!right]
     {\nohyphens#2}%
   \egroup}

\setuphead
  [\v!chapter]
  [\c!command=\koptitel,
   \c!style=\bfc]

\protect \endinput
