1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
%D \module
%D [ file=meta-dum,
%D version=2003.03.21,
%D title=\METAPOST\ Graphics,
%D subtitle=Dummy (External) Graphics,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\unprotect
%D This library overloads the normal external figure
%D placeholder by a nicer one.
%D
%D \startbuffer
%D \useMPlibrary[dum]
%D
%D \startlinecorrection
%D \useMPgraphic{placeholder}{width=3cm,height=4cm,color=red}
%D \stoplinecorrection
%D
%D \startlinecorrection
%D \useMPgraphic{placeholder}{width=8cm,height=10cm,color=green}
%D \stoplinecorrection
%D
%D \startlinecorrection
%D \externalfigure[unknown-a][width=3cm,height=1cm]
%D \stoplinecorrection
%D
%D \startlinecorrection
%D \externalfigure[unknown-b][width=4cm,height=5cm]
%D \stoplinecorrection
%D \stopbuffer
%D
%D \typebuffer \getbuffer
% currently preparempvariables is unable to resolve number
% fractions like reduction
\startuseMPgraphic{placeholder}{width,height,color}
numeric w, h, d, r ; color c ; path p ;
c := \MPvar{color} ;
w := \MPvar{width} ;
h := \MPvar{height} ;
r := \MPvar{reduction} ;
d := max(w,h) ;
p := unitsquare xyscaled (w,h) ;
fill p withcolor r[.5c,white] ;
for i := 1 upto 60 :
fill fullcircle
scaled (d/5 randomized (d/5))
shifted (center p randomized (d))
withcolor r[c randomized(.3,.9),white] ;
endfor ;
clip currentpicture to p ;
\stopuseMPgraphic
\definepalet
[placeholder]
[1=red,2=green,3=blue,4=cyan,5=magenta,6=yellow]
\newcounter\figurereplacementcycle
\setupexternalfigures
[\c!reductie=0,
\c!tekst=\v!ja]
\def\externalfigurereplacement#1#2#3%
{\getpaletsize[placeholder]%
\doglobal\increment\figurereplacementcycle
\ifnum\figurereplacementcycle>\paletsize
\globallet\figurereplacementcycle\!!plusone
\fi
\weightGRAYfalse % monochrome anyway
\defineoverlay
[\s!dummy]
[\useMPgraphic
{placeholder}%
{width=\figurewidth,
height=\figureheight,
reduction=\@@efreductie,
color=placeholder:\figurereplacementcycle}]%
\expanded{\localframed
[\??ef]
[\c!breedte=\figurewidth,
\c!hoogte=\figureheight,
\c!kader=\v!uit,
\c!strut=\v!nee,
\c!achtergrond=\s!dummy,
\c!voorgrondkleur=white]}%
{\doif\@@eftekst\v!ja
{\infofont\stelinterliniein \nohyphens
\doifelse{#1}\s!dummy \!!doneafalse\!!doneatrue
\doifelse{#2}\s!dummy \!!donebfalse\!!donebtrue
\doifelse{#3}\s!unknown\!!donecfalse\!!donectrue
\if!!donea
name: \expanded{\verbatimstring{#1}}\strut\endgraf
\fi
\if!!doneb
\if!!donea file: \else \if!!donec file: \fi \fi
\expanded{\verbatimstring{#2}}\strut\endgraf
\fi
\if!!donec
state: \expanded{\verbatimstring{#3}}\strut\endgraf
\fi}}}
\def\dummyfigure{\externalfigure[placeholder]}
\protect \endinput
|