[metapost] reverse clip operation
lfinsto1 at gwdg.de
lfinsto1 at gwdg.de
Tue Sep 19 14:36:16 CEST 2006
>
> I would prefer a reverse clipping operation. Would it be possible
> to write a macro, which does a reverse clipping?
>
Perhaps the following will be close to what you want. Please note that
you don't necessarily have to put all of the code within figures, unless
you want it to be output. There are a couple of details involving
`beginfig' and `endfig', but you could look them up, if you have problems.
I haven't tried putting this code in a macro. I can't think of any reason
why it wouldn't work, but one always has to try to be sure.
Laurence Finston
%% ttemp.mp
path p[];
picture q[];
path frame; %% Using `frame' ensures that the images are properly aligned.
frame = (0,0) -- (15cm, 0) -- (15cm, 20cm) -- (0, 20cm) -- cycle;
%% The red ellipse.
beginfig(1);
undraw frame;
pickup pencircle scaled 2pt;
z0 = (10cm, 10cm);
p0 = fullcircle xscaled 5cm yscaled 3cm rotated 30 shifted z0;
filldraw p0 withcolor red;
q0 = currentpicture;
endfig;
%% The black line
beginfig(2);
undraw frame;
pickup pencircle scaled 1cm;
draw (1cm, 1cm) -- (13cm, 13cm);
q1 := currentpicture;
endfig;
%% The red ellipse and the black line
beginfig(3);
undraw frame;
addto currentpicture also q0;
addto currentpicture also q1;
endfig;
%% The black line, missing the section corresponding to the red ellipse
beginfig(4);
undraw frame;
currentpicture := q1;
addto currentpicture also q0 withcolor white;
endfig;
end;
%% ttemp.tex
\input epsf
\nopagenumbers
\parindent=0pt
\def\epsfsize#1#2{#1}
\parskip=0pt
\baselineskip=0pt
\vbox to \vsize{%
\vskip.5cm
\line{\hskip1cm\epsffile{ttemp.1}\hss}
\vss
}
\vfil\eject
\vbox to \vsize{%
\vskip.5cm
\line{\hskip1cm\epsffile{ttemp.2}\hss}
\vss
}
\vfil\eject
\vbox to \vsize{%
\vskip.5cm
\line{\hskip1cm\epsffile{ttemp.3}\hss}
\vss
}
\vfil\eject
\vbox to \vsize{%
\vskip.5cm
\line{\hskip1cm\epsffile{ttemp.4}\hss}
\vss
}
\vfil\eject
\bye
More information about the metapost
mailing list