%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 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. \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 \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 % June 22, 2003, this definition was patched to adapt itself % to transparent colors, but ... in 2011 we no longer have % is_transparent so we revert. % % \startuseMPgraphic{placeholder}{width,height,reduction,color} % numeric w, h, d, r ; color c, b, cc ; path p ; boolean t ; % t := is_transparent(\MPvar{color}) ; % c := not_transparent(\MPvar{color}) ; % b := not_transparent(white) ; % w := \MPvar{width} ; % h := \MPvar{height} ; % r := \MPvar{reduction} ; % d := max(w,h) ; % p := unitsquare xyscaled (w,h) ; % cc := r[.5c,b] ; % fill p withcolor if t : transparent(1,.5,cc) else : cc fi ; % for i := 1 upto 60 : % cc := r[c randomized(.3,.9),b] ; % fill fullcircle % scaled (d/5 randomized (d/5)) % shifted (center p randomized (d)) % withcolor if t : transparent(1,.5,cc) else : cc fi ; % endfor ; % clip currentpicture to p ; % \stopuseMPgraphic \startuseMPgraphic{placeholder}{width,height,reduction,color} numeric w, h, d, r ; path p ; if cmykcolor \MPvar{color} : cmykcolor c, b ; b := (0,0,0,0) else : color c, b ; ; b := (1,1,1) fi ; 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,b] ; for i := 1 upto 60 : fill fullcircle scaled (d/5 randomized (d/5)) shifted (center p randomized (d)) withcolor r[c randomized(.3,.9),b] ; endfor ; clip currentpicture to p ; \stopuseMPgraphic \definepalet [placeholder] [1=red,2=green,3=blue,4=cyan,5=magenta,6=yellow] % \newcounter \figurereplacementcycle \let\figurereplacementcycle\relax \setupexternalfigures [\c!reduction=0, \c!text=\v!yes] \let\normalexternalfigurereplacement\externalfigurereplacement \unexpanded\def\externalfigurereplacement#1#2#3% {\getpaletsize[placeholder]% \ifx\figurereplacementcycle\relax \getrandomnumber \figurereplacementcycle \!!plusone \paletsize \globallet \figurereplacementcycle \figurereplacementcycle \else \doglobal\increment\figurereplacementcycle \fi \ifnum\figurereplacementcycle>\paletsize \globallet\figurereplacementcycle\!!plusone \fi \defineoverlay [\s!dummy] [\useMPgraphic {placeholder}% {width=\figurewidth, height=\figureheight, reduction=\@@efreduction, color=placeholder:\figurereplacementcycle}]% \expanded{\localframed [\??ef] [\c!width=\figurewidth, \c!height=\figureheight, \c!frame=\v!off, \c!strut=\v!no, \c!background=\s!dummy, \c!foregroundcolor=\s!white]}% {\doif\@@eftext\v!yes {\infofont \setupinterlinespace \dohyphens % \nohyphens \edef\tempa{#1}\ifx\tempa\s!dummy\let\tempa\empty\fi \edef\tempb{#2}\ifx\tempb\s!dummy\let\tempb\empty\fi \edef\tempc{#3}\ifx\tempc\s!dummy\let\tempc\empty\fi \ifx\tempa\empty\else name: \expanded{\verbatimstring{#1}}\strut\endgraf \fi \ifx\tempb\empty\else \ifx\tempa\empty\ifx\tempc\empty\else file: \fi\else file: \fi \expanded{\verbatimstring{#2}}\strut\endgraf \fi \ifx\tempc\empty\else state: \expanded{\verbatimstring{#3}}\strut\endgraf \fi}}} \unexpanded\def\dummyfigure {\externalfigure[placeholder]} %D \starttyping %D \externalfigure[mediashow.swf][comment={Alas, we have no nice preview},background=figure:comment] %D \externalfigure[mediashow.swf][comment={Alas, we have no nice preview},background=figure:dummy] %D \externalfigure[mediashow.swf][background=figure:dummy] %D \stoptyping \defineframed [figurecomment] [\c!background=\v!color, \c!backgroundcolor=\v!gray, \c!frame=\v!off, \c!foregroundstyle=\ttbf, \c!align={\v!middle,\v!lohi}, \c!height=\figureheight, \c!width=\figurewidth] \defineframed [figuredummy] [\c!background=figure:placeholder, \c!foregroundcolor=white, \c!backgroundcolor=\v!gray, \c!frame=\v!off, \c!foregroundstyle=\ttbf, \c!align={\v!middle,\v!lohi}, \c!height=\figureheight, \c!width=\figurewidth] \defineoverlay [figure:placeholder] [\externalfigurereplacement{}{}{}] \defineoverlay [figure:comment] [\figurecomment{\@@efcomment}] \defineoverlay [figure:dummy] [\figuredummy{\@@efcomment}] \setupexternalfigures [comment=] \protect \endinput