back-trf.mkxl /size: 1977 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=back-trf,
3%D        version=2019.02.08, % 2009.04.15,
4%D          title=\CONTEXT\ Backend Macros,
5%D       subtitle=Transformations,
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\unprotect
15
16\registerctxluafile{back-trf}{autosuffix}
17
18% rotation
19
20\permanent\protected\def\dostartrotation#1%
21  {\forcecolorhack
22   \clf_startrotation#1\relax} % todo: implement without Q q
23
24\permanent\protected\def\dostoprotation
25  {\clf_stoprotation
26   \forcecolorhack}
27
28% scaling
29
30\permanent\protected\def\dostartscaling#1#2%
31  {\forcecolorhack
32   \clf_startscaling rx #1 ry #2\relax}
33
34\permanent\protected\def\dostopscaling
35  {\clf_stopscaling
36   \forcecolorhack}
37
38% mirroring
39
40\permanent\protected\def\dostartmirroring
41  {\clf_startmirroring}
42
43\permanent\protected\def\dostopmirroring
44  {\clf_stopmirroring}
45
46% transform
47
48\permanent\protected\def\dotransformnextbox#1#2#3#4#5#6%
49  {\dowithnextbox{\dodotransformnextbox{#1}{#2}{#3}{#4}{#5}{#6}}}
50
51\permanent\protected\def\dodotransformnextbox#1#2#3#4#5#6%
52  {\hpack
53     {\kern #5\onebasepoint
54      \raise#6\onebasepoint
55      \hpack
56        {\clf_startmatrix rx #1 sx #2 sy #3 ry #4\relax
57         \box\nextbox
58         \clf_stopmatrix}}}
59
60%D \macros
61%D   {dostartclipping,dostopclipping}
62%D
63%D Clipping is implemented in such a way that an arbitrary code can be fed.
64%D
65%D \starttyping
66%D \dostartclipping {pathname} {width} {height}
67%D \dostopclipping
68%D \stoptyping
69
70\mutable\let\MPclippath\empty
71
72\permanent\protected\def\dostartclipping#1#2#3% we can move this to lua and only set a box here
73  {\forcecolorhack
74   \meta_grab_clip_path{#1}{#2}{#3}%
75   \clf_startclipping{\MPclippath}%
76   \glet\MPclippath\empty}
77
78\permanent\protected\def\dostopclipping
79  {\clf_stopclipping}
80
81\protect \endinput
82