mp-crop.mpiv /size: 7497 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=mp-crop.mpiv,
3
%D version=2011.06.23,
4
%D title=\CONTEXT\ \METAPOST\ graphics,
5
%D subtitle=Cropmarks,
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
if
known
context_crop
:
endinput
;
fi
;
15 16
boolean
context_crop
;
context_crop
:
=
true
;
17 18
vardef
crop_marks_lines
(
expr
box
,
len
,
offset
,
nx
,
ny
,
boxtoo
)
=
19
save
p
;
picture
p
;
save
w
,
h
,
x
,
y
;
numeric
w
,
h
,
x
,
y
;
20
p
:
=
image
(
21
x
:
=
if
nx
=
0
:
1
else
:
nx
-
1
fi
;
22
y
:
=
if
ny
=
0
:
1
else
:
ny
-
1
fi
;
23
w
:
=
bbwidth
(
box
)
/
x
;
24
h
:
=
bbheight
(
box
)
/
y
;
25
for
i
=
0
upto
y
:
26
draw
(
(
llcorner
box
)
--
(
llcorner
box
)
shifted
(
-
len
,
0
)
)
shifted
(
-
offset
,
i
*
h
)
;
27
draw
(
(
lrcorner
box
)
--
(
lrcorner
box
)
shifted
(
len
,
0
)
)
shifted
(
offset
,
i
*
h
)
;
28
endfor
;
29
for
i
=
0
upto
x
:
30
draw
(
(
llcorner
box
)
--
(
llcorner
box
)
shifted
(
0
,
-
len
)
)
shifted
(
i
*
w
,
-
offset
)
;
31
draw
(
(
ulcorner
box
)
--
(
ulcorner
box
)
shifted
(
0
,
len
)
)
shifted
(
i
*
w
,
offset
)
;
32
endfor
;
33
if
boxtoo
:
34
for
i
=
0
upto
x
-1
:
35
for
j
=
0
upto
y
-1
:
36
draw
box
enlarged
1
/
8
shifted
(
i
*
w
,
j
*
h
)
dashed
evenly
withpen
pencircle
scaled
1
/
4
;
37
endfor
;
38
endfor
;
39
fi
;
40
)
;
41
setbounds
p
to
box
;
42
p
43
enddef
;
44 45
vardef
crop_marks_cmyk
=
46
pickup
pencircle
scaled
1
/
2
;
47
save
p
;
picture
p
;
p
:
=
image
(
48
fill
ulcircle
scaled
12.5
withcolor
(
1
,
0
,
0
,
0
)
;
49
fill
urcircle
scaled
12.5
withcolor
(
0
,
1
,
0
,
0
)
;
50
fill
lrcircle
scaled
12.5
withcolor
(
0
,
0
,
1
,
0
)
;
51
fill
llcircle
scaled
12.5
withcolor
(
0
,
0
,
0
,
1
)
;
52
draw
(
-10
,
0
)
--
(
10
,
0
)
;
53
draw
(
0
,
-10
)
--
(
0
,
10
)
;
54
draw
fullcircle
scaled
12.5
;
55
)
;
56
setbounds
p
to
fullsquare
scaled
20
;
57
p
58
enddef
;
59 60
vardef
crop_marks_gray
=
61
save
p
;
picture
p
;
p
:
=
image
(
62
fill
ulcircle
scaled
12.5
withcolor
(
0.00
)
;
63
fill
urcircle
scaled
12.5
withcolor
(
0.25
)
;
64
fill
lrcircle
scaled
12.5
withcolor
(
0.50
)
;
65
fill
llcircle
scaled
12.5
withcolor
(
0.75
)
;
66
draw
(
-10
,
0
)
--
(
10
,
0
)
;
67
draw
(
0
,
-10
)
--
(
0
,
10
)
;
68
draw
(
-6
,
0
)
--
(
6
,
0
)
withcolor
white
;
69
draw
(
0
,
-6
)
--
(
0
,
6
)
withcolor
white
;
70
draw
fullcircle
scaled
12.5
;
71
)
;
72
setbounds
p
to
fullsquare
scaled
20
;
73
p
74
enddef
;
75 76
vardef
crop_marks_cmykrgb
=
77
save
p
;
picture
p
;
p
:
=
image
(
78
fill
ulcircle
scaled
15
withcolor
(
1
,
0
,
0
)
;
79
fill
urcircle
scaled
15
withcolor
(
0
,
1
,
0
)
;
80
fill
lrcircle
scaled
15
withcolor
(
0
,
0
,
1
)
;
81
fill
llcircle
scaled
15
withcolor
(
.5
,
.5
,
.5
)
;
82
fill
ulcircle
scaled
10
withcolor
(
1
,
0
,
0
,
0
)
;
83
fill
urcircle
scaled
10
withcolor
(
0
,
1
,
0
,
0
)
;
84
fill
lrcircle
scaled
10
withcolor
(
0
,
0
,
1
,
0
)
;
85
fill
llcircle
scaled
10
withcolor
(
0
,
0
,
0
,
1
)
;
86
draw
(
-10
,
0
)
--
(
10
,
0
)
;
87
draw
(
0
,
-10
)
--
(
0
,
10
)
;
88
draw
fullcircle
scaled
10
;
89
draw
fullcircle
scaled
15
;
90
)
;
91
setbounds
p
to
fullsquare
scaled
20
;
92
p
93
enddef
;
94 95
vardef
crop_color
(
expr
c
,
h
,
w
,
dx
,
dy
,
ts
)
=
96
image
(
97
save
p
;
path
p
;
98
for
i
=
1
upto
6
:
99
p
:
=
fullsquare
100
xscaled
w
101
yscaled
h
102
shifted
(
dx
,
dy
-
i
*
h
)
;
103
fill
p
104
withcolor
(
crop_colors
[
i
]
*
c
)
;
105
draw
textext
(
"
\format{'@0.2f',
"
&
decimal
crop_colors
[
i
]
&
"
}
"
)
106
scaled
ts
107
shifted
center
p
withcolor
white
;
108
endfor
;
109
)
110
enddef
;
111 112
vardef
crop_gray
(
expr
c
,
h
,
w
,
dx
,
dy
,
ts
)
=
113
image
(
114
save
p
;
path
p
;
115
for
i
=
.05
step
.05
until
1
:
116
p
:
=
fullsquare
117
xscaled
w
118
yscaled
h
119
shifted
(
20
*
(
i
-1
)
*
w
+
dx
,
dy
)
;
120
fill
p
121
withcolor
(
i
*
c
)
;
122
draw
textext
(
"
\format{'@0.2f',
"
&
decimal
i
&
"
}
"
)
123
scaled
ts
124
shifted
center
p
withcolor
white
;
125
endfor
;
126
)
127
enddef
;
128 129
% draw crop_marks_cmyk shifted llcorner more ;
130
% draw crop_marks_cmyk shifted lrcorner more ;
131
% draw crop_marks_cmyk shifted ulcorner more ;
132
% draw crop_marks_cmyk shifted urcorner more ;
133 134
def
page_marks_add_color
(
expr
width
,
height
,
length
,
offset
)
=
% todo: namespace
135 136
pickup
pencircle
scaled
1
/
2
;
interim
linecap
:
=
squared
;
interim
linejoin
:
=
butt
;
137 138
path
page
;
page
:
=
fullsquare
xscaled
width
yscaled
height
;
139
path
more
;
more
:
=
page
enlarged
(
offset
+
length
/
2
,
offset
+
length
/
2
)
;
140 141
numeric
crop_colors
[
]
;
142
crop_colors
[
1
]
:
=
1
;
143
crop_colors
[
2
]
:
=
0.95
;
144
crop_colors
[
3
]
:
=
0.75
;
145
crop_colors
[
4
]
:
=
0.50
;
146
crop_colors
[
5
]
:
=
0.25
;
147
crop_colors
[
6
]
:
=
0.05
;
148 149
numeric
h
;
h
:
=
height
/
20
;
150
numeric
w
;
w
:
=
width
/
20
;
151
numeric
d
;
d
:
=
offset
+
length
/
2
;
152 153
draw
crop_color
(
(
1
,
0
,
0
,
0
)
,
h
,
length
,
xpart
ulcorner
page
-
d
,
10
h
,
length
/
20
)
;
154
draw
crop_color
(
(
0
,
1
,
0
,
0
)
,
h
,
length
,
xpart
ulcorner
page
-
d
,
3.5
h
,
length
/
20
)
;
155
draw
crop_color
(
(
0
,
0
,
1
,
0
)
,
h
,
length
,
xpart
ulcorner
page
-
d
,
-3
h
,
length
/
20
)
;
156 157
draw
crop_color
(
(
0
,
1
,
1
,
0
)
,
h
,
length
,
xpart
urcorner
page
+
d
,
10
h
,
length
/
20
)
;
158
draw
crop_color
(
(
1
,
0
,
1
,
0
)
,
h
,
length
,
xpart
urcorner
page
+
d
,
3.5
h
,
length
/
20
)
;
159
draw
crop_color
(
(
1
,
1
,
0
,
0
)
,
h
,
length
,
xpart
urcorner
page
+
d
,
-3
h
,
length
/
20
)
;
160 161
draw
crop_gray
(
(
0
,
0
,
0
,
1
)
,
length
,
w
,
-
xpart
llcorner
page
,
-
ypart
llcorner
page
+
d
,
w
/
20
)
;
162
draw
crop_gray
(
(
1
,
0
,
0
,
0
)
,
length
/
3
,
w
,
-
xpart
llcorner
page
,
ypart
llcorner
page
-
d
+
1
length
/
3
,
w
/
20
)
;
163
draw
crop_gray
(
(
0
,
1
,
0
,
0
)
,
length
/
3
,
w
,
-
xpart
llcorner
page
,
ypart
llcorner
page
-
d
-
0
length
/
3
,
w
/
20
)
;
164
draw
crop_gray
(
(
0
,
0
,
1
,
0
)
,
length
/
3
,
w
,
-
xpart
llcorner
page
,
ypart
llcorner
page
-
d
-
1
length
/
3
,
w
/
20
)
;
165 166
setbounds
currentpicture
to
page
;
167 168
enddef
;
169 170
def
page_marks_add_marking
(
expr
width
,
height
,
length
,
offset
)
=
% todo: namespace
171 172
pickup
pencircle
scaled
1
/
2
;
interim
linecap
:
=
squared
;
interim
linejoin
:
=
butt
;
173 174
path
page
;
page
:
=
fullsquare
xscaled
width
yscaled
height
;
175
path
more
;
more
:
=
page
enlarged
(
offset
+
length
/
2
,
offset
+
length
/
2
)
;
176 177
draw
crop_marks_gray
shifted
center
(
topboundary
more
)
shifted
(
0
,
offset
+
length
)
;
178
draw
crop_marks_cmyk
shifted
center
(
bottomboundary
more
)
shifted
(
0
,
-
offset
-
length
)
;
179 180
setbounds
currentpicture
to
page
;
181 182
enddef
;
183 184
def
page_marks_add_lines
(
expr
width
,
height
,
length
,
offset
,
nx
,
ny
,
boxtoo
)
=
% todo: namespace
185 186
pickup
pencircle
scaled
1
/
2
;
interim
linecap
:
=
squared
;
interim
linejoin
:
=
butt
;
187 188
path
page
;
page
:
=
fullsquare
xscaled
width
yscaled
height
;
189
path
more
;
more
:
=
page
enlarged
(
offset
+
length
/
2
,
offset
+
length
/
2
)
;
190 191
draw
crop_marks_lines
(
page
,
length
,
offset
,
nx
,
ny
,
boxtoo
)
;
192 193
setbounds
currentpicture
to
page
;
194 195
enddef
;
196 197
def
page_marks_add_number
(
expr
width
,
height
,
length
,
offset
,
n
)
=
% todo: namespace
198 199
pickup
pencircle
scaled
1
/
2
;
interim
linecap
:
=
squared
;
interim
linejoin
:
=
butt
;
200 201
path
page
;
page
:
=
fullsquare
xscaled
width
yscaled
height
;
202
path
more
;
more
:
=
page
enlarged
(
offset
+
length
/
2
,
offset
+
length
/
2
)
;
203 204
for
s
=
llcorner
more
,
lrcorner
more
,
ulcorner
more
,
urcorner
more
:
205
draw
textext
(
decimal
n
)
shifted
s
;
206
endfor
;
207 208
setbounds
currentpicture
to
page
;
209 210
enddef
;
211