%$Id: x.mp,v 1.1 2005/09/27 22:22:45 karl Exp $ %*********************************************************************** prologues := 1; defaultfont := "ptmr8r"; defaultscale := 20/fontsize defaultfont; %*********************************************************************** vardef fuzz = uniformdeviate(2) - 1 enddef; vardef zfuzz = (fuzz, fuzz) enddef; def drawpot = draw z.pot0--z.pot1--z.pot2--z.pot3 withpen pencircle scaled 6; enddef; def drawin = fill z.in0 -- z.in1 -- z.in2 -- z.in3 -- cycle withcolor incolor; enddef; def drawneedle = fill z.needle0 {dir 180} ... z.needle1 -- z.needle2 -- z.needle3 ... {dir 0} z.needle4 -- cycle withcolor needlecolor; if infill > 0: draw z.needle0 {dir 180} ... z.needle1 -- z.needle2 -- z.needle3 ... {dir 0} z.needle4 withpen pencircle scaled 2 withcolor incolor; fi; enddef; %*********************************************************************** def calcpoints = z.pot0 = (-xpart picsize/8, -ypart picsize/5) + zfuzz; z.pot1 = (xpart picsize/8, -ypart picsize/5) + zfuzz; z.pot2 = (xpart picsize/8, ypart picsize/5) + zfuzz; z.pot3 = (-xpart picsize/8, ypart picsize/5) + zfuzz; z.needle0 = 0.4[z.pot1, z.pot2]; z.needle4 = 0.6[z.pot1, z.pot2]; z.needle2 = (0.5[z.pot0, z.pot3] + 0.2(z.pot0-z.pot1)) rotatedaround(0.5[z.pot1, z.pot2], bendangle); p := z.needle2 ... {dir 0}0.5[z.pot1, z.pot2]; z0 = point 0.15 of p; z.needle1 = z0 - 0.5(z.needle4-z.needle0) rotated angle direction 0.2 of p; z.needle3 = z0 + 0.5(z.needle4-z.needle0) rotated angle direction 0.2 of p; if infill > 0: z.in0 = infill[z.pot1, z.pot0]; z.in3 = infill[z.pot2, z.pot3]; else: z.in0 = z.pot1; z.in3 = z.pot2; fi; z.in1 = z.pot1; z.in2 = z.pot2; enddef; %*********************************************************************** def frameit = path p; picture q; dist := 15; corner := 35; clearxy; y0 = dist + fuzz; y1 = dist + fuzz; ypart picsize - y5 = dist + fuzz; ypart picsize - y4 = dist + fuzz; x7 = dist + fuzz; x6 = dist + fuzz; xpart picsize - x2 = dist + fuzz; xpart picsize - x3 = dist + fuzz; y7 = corner + fuzz; y2 = corner + fuzz; x0 = corner + fuzz; x5 = corner + fuzz; xpart picsize - x1 = corner + fuzz; xpart picsize - x4 = corner + fuzz; ypart picsize - y6 = corner + fuzz; ypart picsize - y3 = corner + fuzz; p := z0 -- z1 {z1 - z0} ... {z3 - z2} z2 -- z3 {z3 - z2} ... {z5 - z4} z4 -- z5 {z5 - z4} ... {z7 - z6} z6 -- z7 {z7 - z6} ... {z1 - z0} cycle; currentpicture := currentpicture shifted 0.5picsize; q := currentpicture; clip q to p; clearit; fill unitsquare xscaled xpart picsize yscaled ypart picsize withcolor black; unfill p; draw q; enddef; %*********************************************************************** def doframes(expr n)(text t) = for j = 0 upto n - 1: k := j / n; beginfig(i) t; frameit; endfig; i := i + 1; endfor; enddef; %*********************************************************************** def curtainbackground = fill unitsquare xscaled xpart picsize yscaled ypart picsize shifted -0.5 picsize withcolor curtaincolor; enddef; def blackbackground = fill unitsquare xscaled xpart picsize yscaled ypart picsize shifted -0.5 picsize withcolor black; enddef; %*********************************************************************** pair picsize; picsize=(640,480); maxfill = 0.9; inspeed = 0.01xpart picsize; inatoms = 20; pair at[]; numeric ang[]; color incolor, needlecolor, hotcolor, curtaincolor; curtaincolor := 0.3red; hotcolor := red + 0.2green + 0.2blue; needlecolor := blue; for j := 0 upto inatoms: at[j] := (-j * xpart picsize/30, 0); ang[j] := 0; endfor i := 0; % Intro doframes(10)( blackbackground; ); for k := 5 downto 0: doframes(19)( blackbackground; ); doframes(1)( blackbackground; undraw(-0.5xpart picsize, 0) -- (0.5xpart picsize, 0) withpen pencircle scaled 5; undraw(0,-0.5ypart picsize) -- (0, 0.5ypart picsize) withpen pencircle scaled 5; unfill fullcircle scaled 0.3 xpart picsize; draw thelabel(decimal(k) infont defaultfont scaled 10, origin); ); endfor; doframes(30)( curtainbackground; ); doframes(40)( curtainbackground; undraw thelabel("The Poor Ion Emitter" infont defaultfont scaled 4, origin) rotated fuzz shifted zfuzz; ); doframes(10)( curtainbackground; ); doframes(40)( curtainbackground; undraw thelabel("A Short Movie by" infont defaultfont scaled 4, origin) rotated fuzz shifted zfuzz; ); doframes(10)( curtainbackground; ); doframes(30)( curtainbackground; picture pp; pp := thelabel("Hartmut Henkel" infont defaultfont scaled 4, origin); undraw pp rotated fuzz shifted zfuzz; fill llcorner pp shifted 7zfuzz -- lrcorner pp shifted 7zfuzz -- urcorner pp shifted 7zfuzz -- ulcorner pp shifted 7zfuzz -- cycle withcolor red + green; ); doframes(40)( blackbackground ); % Heating doframes(50)( infill := maxfill; incolor := k * hotcolor; bendangle := 0; calcpoints; drawin; drawneedle; drawpot; ); % Emitting doframes(120)( infill := maxfill * (1 - k); incolor := hotcolor; bendangle := fuzz; calcpoints; drawin; drawneedle; drawpot; for jj = 0 upto inatoms: if xpart at[jj] > 0: at[jj] := at[jj] shifted (inspeed, 3fuzz); ang[jj] := ang[jj] + 5fuzz; else: at[jj] := at[jj] shifted (inspeed, 0); fi; if xpart(at[jj]) > 0: draw thelabel.lft("In", origin) rotated ang[jj] shifted ((x.needle2,0.5[y.pot1,y.pot2])-at[jj]) withcolor incolor; if xpart at[jj] > x.needle2 + 0.5xpart picsize: at[jj] := (xpart at[jj] - (x.needle2+0.5xpart picsize), 0); ang[jj] := 0; fi; fi; endfor; ); % Empty doframes(15)( infill := 0; bendangle := 30 * k; calcpoints; drawin; drawneedle; drawpot; for jj = 0 upto inatoms: if xpart at[jj] > 0: at[jj] := at[jj] shifted (inspeed, 3fuzz); ang[jj] := ang[jj] + 5fuzz; draw thelabel.lft("In", origin) rotated ang[jj] shifted ((x.needle2,0.5[y.pot1,y.pot2])-at[jj]) withcolor incolor; fi; endfor; ); % End doframes(30)( infill := 0; bendangle := 30; calcpoints; drawin; drawneedle; drawpot; for jj = 0 upto inatoms: if xpart at[jj] > 0: at[jj] := at[jj] shifted (inspeed, 3fuzz); ang[jj] := ang[jj] + 5fuzz; draw thelabel.lft("In", origin) rotated ang[jj] shifted ((x.needle2,0.5[y.pot1,y.pot2])-at[jj]) withcolor incolor; fi; endfor; ); %Extro doframes(10)( blackbackground; ); doframes(30)( curtainbackground; undraw thelabel("The End" infont defaultfont scaled 4, origin) rotated fuzz shifted zfuzz; ); doframes(20)( curtainbackground; ); doframes(10)( blackbackground; ); %*********************************************************************** end