meta-imp-grid.mkiv /size: 1831 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=meta-imp-grid,
3%D        version=2016.01.08,
4%D          title=\METAPOST\ Graphics,
5%D       subtitle=Grid Tracing,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\startMPextensions
15    color mfun_grid_lgc[] ;
16    numeric mfun_grid_lgi ;
17    mfun_grid_lgc[1] := red ;
18    mfun_grid_lgc[2] := green ;
19    mfun_grid_lgc[3] := blue ;
20    mfun_grid_lgi := 1 ;
21\stopMPextensions
22
23\startuseMPgraphic{linegrid}
24  % if unknown mfun_grid_lgi :
25  %     color mfun_grid_lgc[] ;
26  %     numeric mfun_grid_lgi ;
27  %     mfun_grid_lgc[1] := red ;
28  %     mfun_grid_lgc[2] := green ;
29  %     mfun_grid_lgc[3] := blue ;
30  %     mfun_grid_lgi := 1 ;
31  % elseif mfun_grid_lgi = 3 :
32    if mfun_grid_lgi = 3 :
33        mfun_grid_lgi := 1 ;
34    else :
35        mfun_grid_lgi := mfun_grid_lgi + 1 ;
36    fi ;
37    draw image (
38        save f, t ;
39        pair f, t ;
40        f := (0,-2*LineHeight) ;
41        t := (0, 2*LineHeight) ;
42        for i=ypart f - eps step LineHeight/5 until ypart t + eps:
43            draw (-EmWidth,i) -- (0,i) ;
44        endfor ;
45        draw f -- t ;
46        draw (-EmWidth,0) -- (EmWidth,0) ;
47  % ) shifted (-mfun_grid_lgi*EmWidth/3,0) withcolor mfun_grid_lgc[mfun_grid_lgi] ;
48    ) shifted (-EmWidth/2,0) withcolor mfun_grid_lgc[mfun_grid_lgi] ;
49    setbounds currentpicture to origin -- cycle ;
50\stopuseMPgraphic
51
52\unexpanded\def\showlinegrid{\dontleavehmode\smash{\useMPgraphic{linegrid}}}
53
54\continueifinputfile{meta-imp-grid.mkiv}
55
56\starttext
57
58\showlinegrid \input tufte \par
59\showlinegrid \input tufte \par
60\showlinegrid \input ward \par
61\showlinegrid \input ward \par
62
63\stoptext
64