meta-dum.mkii / last modification: 2020-01-30 14:15
%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 This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.


%D This library overloads the normal external figure
%D placeholder by a nicer one.
%D \startbuffer
%D \useMPlibrary[dum]
%D \startlinecorrection
%D \externalfigure[unknown-a][width=3cm,height=1cm]
%D \stoplinecorrection
%D \startlinecorrection
%D \externalfigure[unknown-b][width=4cm,height=5cm]
%D \stoplinecorrection
%D \stopbuffer
%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

    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 ;


% \newcounter \figurereplacementcycle




     \getrandomnumber \figurereplacementcycle \!!plusone \paletsize
     \globallet \figurereplacementcycle \figurereplacementcycle
   \weightGRAYfalse % monochrome anyway
        {\infofont \setupinterlinespace \dohyphens % \nohyphens
         \doifelse{#1}\s!dummy  \!!doneafalse\!!doneatrue
         \doifelse{#2}\s!dummy  \!!donebfalse\!!donebtrue
           name: \expanded{\verbatimstring{#1}}\strut\endgraf
           \if!!donea file: \else \if!!donec file: \fi \fi
           state: \expanded{\verbatimstring{#3}}\strut\endgraf


\protect \endinput