% The MuPAD logo in METAFONT.
%
% ccr@mupad.de, started on Feb 25 1999
%
%% Copyright 2002 SciFace Software GmbH
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% This program consists of the files Mhelp.sty, Mhyper.sty,
% Mcompat.sty, Mbook.sty, Mreprt.sty, Mfonts.sty, Mwrite.sty,
% and MuPAD.mf.
%
%
% The MuPAD logo is actually simple.  It consists of eight balls
% connected by tubes, the whole thing forming a cube in isometric
% display.  Let's go ahead and define the things:

% the direction of the lightsource
lightdir=135;
def ball(expr midpoint, r) =
  begingroup
    save currentpen,x,y; pen currentpen;
    pickup pencircle scaled 2r;
    drawdot midpoint;
    pickup pencircle scaled 0.4r;
    z1-midpoint = (0.5r, 0) rotated lightdir;
    undrawdot z1;
  endgroup enddef;

def tube(expr startpos, endpos, startwidth, endwidth) =
  begingroup
    save currentpen; pen currentpen;
    save x, y, theta;
    pickup pencircle scaled startwidth; drawdot startpos;
    pickup pencircle scaled endwidth;   drawdot endpos;
    z1=startpos; z2=endpos;
    penpos1(startwidth, angle(z1-z2) + 90);
    penpos2(endwidth,   angle(z1-z2) + 90);
    penstroke z1e..z2e;
  endgroup enddef;


% Now, the fun starts
mode_setup;

o#:=-1/5pt#;
define_corrected_pixels(o);

beginchar("A",8pt#,8pt#,0); "The basic logo";
  frontballsize = w/16;
  backballsize = 0.8*frontballsize;

  bts=0.7*backballsize;
  fts=0.7*frontballsize;
  
  x1=x3=frontballsize+0.1w; y1=y2=frontballsize-o;
  x2=x4=x1+0.5w; y3=y4=y1+0.5w;
  for i=1 upto 4:
    z[i]'=z[i]+(0.2w,0.2w);
  endfor;
  tube(z1',z2',bts, bts);
  tube(z2',z4',bts, bts);
  tube(z3',z4',bts, bts);
  tube(z3',z1',bts, bts);
  for i=1 upto 4:
    ball(z[i]',backballsize);
    tube(z[i]',z[i],bts,fts);
    ball(z[i], frontballsize);
  endfor;
  tube(z1, z2, fts, fts);
  tube(z2, z4, fts, fts);
  tube(z3, z4, fts, fts);
  tube(z3, z1, fts, fts);
  
endchar;

% For the documentation, we need some warning sign.
% The following is just a rough sketch.

beginchar("!", 24pt#, 20pt#, 0); "Mwarning";
  save ch, cw;
  
  (z1-z2) = (z6-z5);
  (z2-z3) = (z7-z6) = (z1-z2) rotated -45;
  (z3-z4) = (z8-z7) = (z1-z2) rotated -90;
  (z4-z5) = (z1-z8) = (z1-z2) rotated -135;

  x1 = x8 = w-x4 = 0.1*w;

  y6 = 0;
  
  pickup pencircle scaled 1pt;
  draw z1--z2--z3--z4--z5--z6--z7--z8--cycle;

  % the centers of the four letters
  y10 = y11 = y12 = y13 = 0.5[y2,y7];
  x10 = .2[x1,x4];
  x13 = x4 - (x10-x1);
  (x11 - x10) = (x12 - x11) = (x13 - x12) = 1.4*cw = 0.8*ch;

  % optical corrections
  x12 := .475[x11,x13];
  
%  for i=10 upto 13:
%    drawdot(z[i]);
%  endfor;
  
  pickup pencircle scaled .7pt;

  % N
  draw ( z10 + (-.5cw, -.5ch) )
  -- ( z10 + (-.5cw, .5ch) )
  -- ( z10 + (.5cw, -.5ch) )
  -- ( z10 + (.5cw, .5ch) );

  % O
  draw ( z11 + (-0.5*cw, 0.5*ch - 0.5*cw) ){up}
  .. {right}( z11 + (0, 0.5*ch)){right}
  .. {down} ( z11 + (0.5*cw, 0.5*ch - 0.5*cw) ) {down}
  .. {down} ( z11 + (0.5*cw, - 0.5*ch + 0.5*cw) ) {down}
  .. {left} ( z11 + (0, -0.5*ch)){left}
  .. {up}   ( z11 + (-0.5*cw, - 0.5*ch + 0.5*cw) ) {up} .. cycle;

  % T
  draw ( z12 + (-0.6*cw, 0.5*ch) ) -- ( z12 + (0.6*cw, 0.5*ch) );
  draw ( z12 + ( 0, -0.5*ch ) ) -- ( z12 + ( 0, 0.5*ch ) );

  % E
  draw ( z13 + (.5cw, .5ch))
  -- ( z13 + (-.5cw, .5ch))
  -- ( z13 + (-.5cw, -.5ch))
  -- ( z13 + (.5cw, -.5ch));

  draw (z13 + (-.5cw,0)) -- (z13 + (.4cw, 0));
  
%  % S
%  draw ( z10 + (.5cw, .5ch-.5cw) ) {up}
%  .. {left} (z10 + (0, .5ch)){left}
%  .. {down} (z10 + (-.5cw, .5ch-.5cw)){down}
%  .. z10
%  .. {down} (z10 + (.5cw, .5cw-.5ch)) {down}
%  .. {left} (z10 + (0, -.5ch) ) {left}
%  .. {up} (z10 + (-.5cw, .5cw-.5ch));
%  
%  % T
%  draw ( z11 + (-0.6*cw, 0.5*ch) ) -- ( z11 + (0.6*cw, 0.5*ch) );
%  draw ( z11 + ( 0, -0.5*ch ) ) -- ( z11 + ( 0, 0.5*ch ) );
%
%  % O
%  draw ( z12 + (-0.5*cw, 0.5*ch - 0.5*cw) ){up}
%  .. {right}( z12 + (0, 0.5*ch)){right}
%  .. {down} ( z12 + (0.5*cw, 0.5*ch - 0.5*cw) ) {down}
%  .. {down} ( z12 + (0.5*cw, - 0.5*ch + 0.5*cw) ) {down}
%  .. {left} ( z12 + (0, -0.5*ch)){left}
%  .. {up}   ( z12 + (-0.5*cw, - 0.5*ch + 0.5*cw) ) {up} .. cycle;
%
%  % P
%  draw ( z13 + (-.5cw, -.5ch) ) -- ( z13 + (-.5cw, .5ch) )
%  -- ( z13 + (.5cw-.25ch, .5ch) ) {right}
%  .. {down}( z13 + (.5cw, .25ch) ){down}
%  .. {left}( z13 + (.5cw-.25ch, 0) )
%  -- ( z13 + (-.5cw, 0) )
endchar;

end.
