meta-imp-clp.mkiv /size: 5208 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=meta-imp-clp,
3
%D version=2000.07.06,
4
%D title=\METAPOST\ Graphics,
5
%D subtitle=Clipping,
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
%D In this library, we define a bunch of clipping paths that
15
%D can be fed to \type {\clip}.
16 17
\startMPclip
{
ellipse
}
18
clip
currentpicture
to
unitcircle
19
xscaled
\width
yscaled
\height
;
20
\stopMPclip
21 22
\startMPclip
{
negellipse
}
23
clip
currentpicture
to
(
unitcircle
peepholed
unitsquare
)
24
xscaled
\width
yscaled
\height
;
25
\stopMPclip
26 27
\startMPclip
{
urellipse
}
28
clip
currentpicture
to
urcircle
scaled
2
29
xscaled
\width
yscaled
\height
;
30
\stopMPclip
31 32
\startMPclip
{
ulellipse
}
33
clip
currentpicture
to
ulcircle
scaled
2
shifted
(
1
,
0
)
34
xscaled
\width
yscaled
\height
;
35
\stopMPclip
36 37
\startMPclip
{
llellipse
}
38
clip
currentpicture
to
llcircle
scaled
2
shifted
(
1
,
1
)
39
xscaled
\width
yscaled
\height
;
40
\stopMPclip
41 42
\startMPclip
{
lrellipse
}
43
clip
currentpicture
to
lrcircle
scaled
2
shifted
(
0
,
1
)
44
xscaled
\width
yscaled
\height
;
45
\stopMPclip
46 47
\startMPclip
{
tellipse
}
48
clip
currentpicture
to
tcircle
shifted
(
.
5
,
0
)
yscaled
2
49
xscaled
\width
yscaled
\height
;
50
\stopMPclip
51 52
\startMPclip
{
bellipse
}
53
clip
currentpicture
to
bcircle
shifted
(
.
5
,
.
5
)
yscaled
2
54
xscaled
\width
yscaled
\height
;
55
\stopMPclip
56 57
\startMPclip
{
lellipse
}
58
clip
currentpicture
to
lcircle
shifted
(
.
5
,
.
5
)
xscaled
2
59
xscaled
\width
yscaled
\height
;
60
\stopMPclip
61 62
\startMPclip
{
rellipse
}
63
clip
currentpicture
to
rcircle
shifted
(
0
,
.
5
)
xscaled
2
64
xscaled
\width
yscaled
\height
;
65
\stopMPclip
66 67
\startMPclip
{
diamond
}
68
clip
currentpicture
to
unitdiamond
69
xscaled
\width
yscaled
\height
;
70
\stopMPclip
71 72
\startMPclip
{
negdiamond
}
73
clip
currentpicture
to
(
unitdiamond
peepholed
unitsquare
)
74
xscaled
\width
yscaled
\height
;
75
\stopMPclip
76 77
\startMPclip
{
urtriangle
}
78
clip
currentpicture
to
urtriangle
scaled
2
79
xscaled
\width
yscaled
\height
;
80
\stopMPclip
81 82
\startMPclip
{
ultriangle
}
83
clip
currentpicture
to
ultriangle
scaled
2
shifted
(
1
,
0
)
84
xscaled
\width
yscaled
\height
;
85
\stopMPclip
86 87
\startMPclip
{
lltriangle
}
88
clip
currentpicture
to
lltriangle
scaled
2
shifted
(
1
,
1
)
89
xscaled
\width
yscaled
\height
;
90
\stopMPclip
91 92
\startMPclip
{
lrtriangle
}
93
clip
currentpicture
to
lrtriangle
scaled
2
shifted
(
0
,
1
)
94
xscaled
\width
yscaled
\height
;
95
\stopMPclip
96 97
% More efficient:
98
%
99
% \def\dosimpleMPclip#1
100
% {clip currentpicture to (#1) xscaled \width yscaled \height ;}
101
%
102
% \def\simpleMPclip#1#2%
103
% {\startMPclip{#1}\dosimpleMPclip{#2}\stopMPclip}
104
%
105
% \simpleMPclip {ellipse} {unitcircle}
106
% \simpleMPclip {diamond} {unitdiamond}
107
%
108
% \simpleMPclip {negellipse} {unitcircle peepholed unitsquare}
109
% \simpleMPclip {negdiamond} {unitdiamond peepholed unitsquare}
110
%
111
% \simpleMPclip {urellipse} {urcircle scaled 2 shifted (0,0)}
112
% \simpleMPclip {ulellipse} {ulcircle scaled 2 shifted (1,0)}
113
% \simpleMPclip {llellipse} {llcircle scaled 2 shifted (1,1)}
114
% \simpleMPclip {lrellipse} {lrcircle scaled 2 shifted (0,1)}
115
%
116
% \simpleMPclip {tellipse} {tcircle shifted (.5,0) yscaled 2}
117
% \simpleMPclip {bellipse} {bcircle shifted (.5,.5) yscaled 2}
118
% \simpleMPclip {lellipse} {lcircle shifted (.5,.5) xscaled 2}
119
% \simpleMPclip {rellipse} {rcircle shifted (0,.5) xscaled 2}
120
%
121
% \simpleMPclip {urtriangle} {urtriangle scaled 2 shifted (0,0)}
122
% \simpleMPclip {ultriangle} {ultriangle scaled 2 shifted (1,0)}
123
% \simpleMPclip {lltriangle} {lltriangle scaled 2 shifted (1,1)}
124
% \simpleMPclip {lrtriangle} {lrtriangle scaled 2 shifted (0,1)}
125 126
%D \in {Figure} [fig:clipping paths] shows which paths are
127
%D predefined. When applied to a whole picture, their usage
128
%D is:
129
%D
130
%D \starttyping
131
%D \clip[nx=1,ny=1,mp=ellipse]{some clippable content}
132
%D \stoptyping
133
%D
134
%D \startbuffer
135
%D \setupclipping [nx=1,ny=1,x=1,y=1]
136
%D \setupblackrules[width=2cm,height=1cm]
137
%D \startcombination[6*3] % \startcombination[6*3]
138
%D {\clip[mp=urellipse] {\blackrule}} {urellipse}
139
%D {\clip[mp=ulellipse] {\blackrule}} {ulellipse}
140
%D {\clip[mp=llellipse] {\blackrule}} {llellipse}
141
%D {\clip[mp=lrellipse] {\blackrule}} {lrellipse}
142
%D {\clip[mp=ellipse] {\blackrule}} {ellipse}
143
%D {\clip[mp=negellipse]{\blackrule}} {negellipse}
144
%D {\clip[mp=tellipse] {\blackrule}} {tellipse}
145
%D {\clip[mp=bellipse] {\blackrule}} {bellipse}
146
%D {\clip[mp=lellipse] {\blackrule}} {lellipse}
147
%D {\clip[mp=rellipse] {\blackrule}} {rellipse}
148
%D {} {}
149
%D {} {}
150
%D {\clip[mp=urtriangle]{\blackrule}} {urtriangle}
151
%D {\clip[mp=ultriangle]{\blackrule}} {ultriangle}
152
%D {\clip[mp=lltriangle]{\blackrule}} {lltriangle}
153
%D {\clip[mp=lrtriangle]{\blackrule}} {lrtriangle}
154
%D {\clip[mp=diamond] {\blackrule}} {diamond}
155
%D {\clip[mp=negdiamond]{\blackrule}} {negdiamond}
156
%D \stopcombination % \stopcombination
157
%D \stopbuffer
158
%D
159
%D \placefigure % \placefigure
160
%D [here][fig:clipping paths]
161
%D {The predefined clipping paths.}
162
%D {\getbuffer} % {\getbuffer}
163 164
\endinput
165