How would I go about coloring the top and bottom of a page in ConTeXt/Metafun?

Currently I am using this code

\definecolor [Top] [h=00ff00]
\definecolor [Bottom] [h=ff0000]
\definecolor [TitleColor] [h=0000ff]
\setupmakeup [CoverPage] [pagestart=yes]
\definehighlight [CoverTitle] [color=TitleColor]

    StartPage ;
         fill Page withcolor \MPcolor{Top} ;
    StopPage ;


    \definedfont[Serif at 20.7pt]\setstrut \strut Author \par
    \definedfont[Serif at 32.7pt]\setstrut \strut \TitleColor{Cover Page Title} \par
    % I would like to separate the top and bottom colors here.
    \definedfont[Serif at 24.9pt]\setstrut \strut \TitleColor{Subhead Title}

Which obviously returns a page with a single color.

I am learning ConTeXt/Metafun, so the above code is "cargo cult"-ish. If there is a better way I would like to know.

  • 1
    Your MWE does not compile on ConTeXt live, because of startmarkup. Do you mean startmakeup ? – sztruks Jan 30 '19 at 20:21
  • Yes, I approximated the code. Sorry about that. – StillSubjectToChange Jan 30 '19 at 20:22
  • I made an edit to your code. Compiles now. – sztruks Jan 30 '19 at 20:24
  • 1
    You don't need \setupcolors [state=start]. Colors are enabled by default in ConTeXt MkIV. – Henri Menke Jan 30 '19 at 21:24

For such specific placement requirements it's probably the easiest to just design the whole page in MetaFun. I have also adapted it to look more more “Motion Mountainy”. The picture shows the mountain Matterhorn, the highest peak in Switzerland. It's royalty free and obtained from here: https://pixabay.com/en/matterhorn-snow-mountain-panorama-3051346/

\setupbodyfont [minion]

\definecolor [Top] [h=a5b291]
\definecolor [Bottom] [h=b7c1a7]
\definecolor [TitleColor] [h=96433a]




    StartPage ;

    numeric w ; w := bbwidth(Page) ;
    numeric h ; h := bbheight(Page) ;

    fill (unitsquare xyscaled (w,.8h)) withcolor \MPcolor{Bottom} ;
    fill (unitsquare xyscaled (w,.2h) yshifted .8h) withcolor \MPcolor{Top} ;
    draw (0,.8h) -- (w,.8h) withpen pensquare scaled 2pt withcolor white ;

    draw textext.rt("\definedfont[Serif at 20.7pt]Author") shifted (.1w,.95h) ;
    draw textext.rt("\titlefont{Serif at 45.2pt} Cover Page Title") shifted (.1w,.85h) withcolor \MPcolor{TitleColor} ;
    draw textext.rt("\titlefont{SerifBold at 20.7pt} Subhead Title") shifted (.1w,.75h) withcolor \MPcolor{TitleColor} ;
    draw textext.rt("\titlefont{SerifBold at 20.7pt} Another subhead") shifted (.1w,.70h) ;

    picture p; p := externalfigure "matterhorn.png" ;
    draw p scaled (w/bbwidth p) ;

    StopPage ;



enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.