Open main menu

Changes

m
added \startTEXpage[pagestate=start] %`pagestate=start` is needed to have incremented page numbering of the pdf
== Finishing Layer ==
The purpose of the finishing layer in the our ConTeXt code is to add the final touches to the drawn layers and to clip the graphic to the same frame. It also includes the addition of page numbering to each page with the help of a Metapost variable, in our case "mypagenumber". We need this method because apparently, it is not possible to use the ConTeXt page numberin numbering on a Metapost page. The finishing layer needs to be applied after drawing all the other layers.
== Layer Sets ==
\startuseMPgraphic{base} %Here in the base, we define the components we will use to draw our images
numeric u; u = 1cm;
numeric framefactor; framefactor = 3.4;path TheFrame ; TheFrame := fullsquare scaled 3.4u xyscaled (framefactor*u, framefactor*u) ; %Needed if you want to have for every page to have the same dimensiondimensions. Use (sqrt(2)*framefactor*u, framefactor*u) for DIN A Landscape ratio of the dimensions.
color stone_color; stone_color = 1/256(199,199,199);
color light_teal_color; light_teal_color = 1/256(154,209,189);
draw textext(decimal(\MPvar{mypagenumber})) scaled .1u withcolor magenta ;
setbounds currentpicture to TheFrame ;
%scaling the page to your preferred dimension:
desiredformat := 150;% In pixels (will be converted by default at 72dpi). The shorter dimension of DIN A4 would be 595 pixels.
currentpicture := currentpicture xysized (desiredformat ,desiredformat ); %for square pages. If DIN A Landscape, use (sqrt(2)*desiredformat ,desiredformat)
\stopuseMPgraphic %finishing
\startuseMPgraphic{Gamma} %this This is a layer subset which will be used more than once. I call it a layer subset and not a layer set because it doesn't include another MPgraphic.
draw layerU ;
draw layerM ;
draw layerW ;
draw layerA ;
\includeMPgraphic{finishing}
\stopuseMPgraphic
\startuseMPgraphic{layersetpage2} %there There should not be a no gap in the sequence of the numbers of the layersetpages
\includeMPgraphic{layersetpage1} ;
draw layerV ;
\includeMPgraphic{finishing}
\stopuseMPgraphic
\includeMPgraphic{layersetpage2} ;
\includeMPgraphic{Gamma} ;
\includeMPgraphic{finishing}\stopuseMPgraphic
\startuseMPgraphic{layersetpre4} %This is a layer set because it includes another MPgraphic. It will be used more than once, but not it will not become a page itself. It's only an intermediate step on the way to the next layersetpage. For that reason, it's not named layersetpage. Because it's coming before the layersetpage4, I call it layersetpre4. If I need another intermediate step stored before layersetpre4, I would call it layersetprepre4. But that's only a naming convention for myself.
\includeMPgraphic{layersetpage1} ;
draw layerY ;
\stopuseMPgraphic %Gamma
\startuseMPgraphic{layersetpage4}
\includeMPgraphic{layersetpre4} ;
label("special!", (z3+z4)/2) rotated 5 withcolor red;
\includeMPgraphic{finishing}
\stopuseMPgraphic
\includeMPgraphic{layersetpage3} ;
draw layerC ;
\includeMPgraphic{finishing}
\stopuseMPgraphic
\includeMPgraphic{layersetpre4} ;
draw layerC ;
\includeMPgraphic{finishing}
\stopuseMPgraphic
\starttext
\dorecurse{6}{ %This loop starts from 1 until the set number. and draws each layersetpage onto its own page. Don't set a number which is higher than the number of your last layersetpage. %By differentiating finishinglayersetpage#1 from layersetpage#1, we can avoid adding \includeMPgraphic{finishing} to each \startuseMPgraphic{layersetpage<number>}. This allows us to apply the scaling of the page to our desiredformat, because the scaling will done only once per \useMPgraphic{}.\startuseMPgraphic{finishinglayersetpage#1}\includeMPgraphic{layersetpage#1} ;\includeMPgraphic{finishing}\stopuseMPgraphic %uncomment if needed: % \setupTEXpage[background=color, backgroundcolor=gray] \startTEXpage[pagestate=start] %`pagestate=start` is needed to have incremented page numbering of the pdf \useMPgraphic{layersetpagefinishinglayersetpage#1}{mypagenumber=#1}
\stopTEXpage
}
12

edits