ConTeXt 中的封面着色

ConTeXt 中的封面着色

我该如何在 ConTeXt/Metafun 中为页面的顶部和底部着色?

目前我正在使用此代码

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

\startuseMPgraphic{Head}
    StartPage ;
         fill Page withcolor \MPcolor{Top} ;
    StopPage ;
\stopuseMPgraphic

\defineoverlay[page][\useMPgraphic{Head}]
\setupbackgrounds[page][background=page]

\starttext
\startmakeup[CoverPage][doublesided=no]
    \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}
\stopmakeup
\stoptext

这显然会返回一个具有单一颜色的页面。

我正在学习 ConTeXt/Metafun,所以上面的代码有点“货物崇拜”的味道。如果有更好的方法,我很想知道。

答案1

对于这种特定的展示位置要求,最简单的方法可能是在 MetaFun 中设计整个页面。我还对其进行了调整,使其看起来更像“Motion Mountainy”。图片显示了瑞士最高峰马特洪峰。它是免版税的,可从此处获取:https://pixabay.com/en/matterhorn-snow-mountain-panorama-3051346/

\setupbodyfont [minion]

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

\define[1]\titlefont{%
  \setcharacterkerning[extrakerning]%
  \cap
  \definedfont[#1]%
  \ignorespaces
}

\starttext

\startMPpage

    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 ;

\stopMPpage

\stoptext

在此处输入图片描述

相关内容