diff options
author | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
commit | 974640d66e61e81cb197ad96fdff7b08343e4c5a (patch) | |
tree | 2e1f75f32f312b7f24ba82b4590ae230bcd6f399 /Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl | |
parent | b4fa72e61230aca75f7f6fbf988821f71edfb6b2 (diff) |
context
git-svn-id: svn://tug.org/texlive/trunk@58167 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl b/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl new file mode 100644 index 00000000000..009149e46ed --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkxl/meta-grd.mkxl @@ -0,0 +1,105 @@ +%D \module +%D [ file=meta-grd, +%D version=2012.06.28, +%D title=\METAPOST\ Graphics, +%D subtitle=grids, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Grids} + +\unprotect + +%D This used to be a \TEX\ method, and a rather old one too. We keep it around but +%D in a more modern way. +%D +%D \startbuffer +%D \basegrid +%D [nx=8,ny=5, +%D dx=.5,dy=.25, +%D unit=cm,scale=2,factor=1, +%D offset=1ex,xstep=2,ystep=1, +%D align=middle,style=\tt\tx] +%D \stopbuffer +%D +%D \typebuffer +%D +%D \placefigure +%D {An example of a grid.} +%D {\getbuffer} + +\startuseMPgraphic{meta:grd:basegrid} + begingroup ; + + save sc, dx, dy, wd, ht, ox, oy, ax, ay ; + + sc = \directdummyparameter\c!factor*\directdummyparameter\c!scale ; + dx = \MPdpar\directdummyparameter\c!dx*sc ; + dy = \MPdpar\directdummyparameter\c!dy*sc ; + wd = \directdummyparameter\c!nx*dx ; + ht = \directdummyparameter\c!ny*dy ; + ox = \MPdpar\directdummyparameter\c!xoffset\relax ; + oy = \MPdpar\directdummyparameter\c!yoffset\relax ; + + if "\directdummyparameter\c!align" = "\v!middle" : + ax = \MPdpar\directdummyparameter\c!dx/2 + ay = \MPdpar\directdummyparameter\c!dy/2 + else : + ax = 0 ; + ay = 0 ; + fi ; + + draw image ( + for i=0 step dx until wd : draw (i,0) -- (i,ht) ; endfor ; + for i=0 step dy until ht : draw (0,i) -- (wd,i) ; endfor ; + ) + withpen pencircle scaled \MPdpar\directdummyparameter\c!rulethickness\space + withcolor "\directdummyparameter\c!rulecolor" ; + + draw image ( + if \directdummyparameter\c!xstep > 0 : + for i=1 step \directdummyparameter\c!xstep until \directdummyparameter\c!nx : + draw thetextext.bot(decimal i,(i*dx-ax,oy)); + endfor ; + fi ; + if \directdummyparameter\c!ystep > 0 : + for i=1 step \directdummyparameter\c!ystep until \directdummyparameter\c!ny : + draw thetextext.lft(decimal i,(ox,i*dy-ay)) ; + endfor ; + fi ; + ) + withcolor "\directdummyparameter\c!color" ; + + endgroup ; +\stopuseMPgraphic + +\permanent\tolerant\protected\def\basegrid[#1]% + {\dontleavehmode + \hbox\bgroup + \getdummyparameters + [\c!nx=10,\c!ny=10,% + \c!dx=.5,\c!dy=.5,% + \c!xstep=0,\c!ystep=0,% + \c!unit=\s!cm,\c!scale=1,\c!factor=1,% + \c!offset=.25\exheight,% + \c!xoffset=\directdummyparameter\c!offset,% + \c!yoffset=\directdummyparameter\c!offset,% + \c!align=,% + \c!color=\currentcolorname,% + \c!rulecolor=\currentcolorname,% + \c!rulethickness=\linewidth,% + #1]% + \usedummystyleandcolor\c!style\c!color + \setexpandeddummyparameter\c!dx{\directdummyparameter\c!dx\directdummyparameter\c!unit}% + \setexpandeddummyparameter\c!dy{\directdummyparameter\c!dy\directdummyparameter\c!unit}% + \useMPgraphic{meta:grd:basegrid}% + \egroup} + +\aliased\let\grid\basegrid + +\protect \endinput |