ifthenInLabel.mp

verbatimtex
%&latex
\documentclass{article}
\newcounter{i} \setcounter{i}{0}   % LaTeX counter i=0
\newcounter{j} \setcounter{j}{0}   % LaTeX counter j=0
\usepackage{ifthen}

\begin{document}
etex

breite=250; hoehe=175;
R:=.4hoehe;
v:=35;

beginfig(1)
  %
  % --- Left polygon ---
  %
  for k=0 upto 7: z[k]=(.5breite+R*cosd 360/8k-v, .5hoehe+R*sind 360/8k); endfor 
  %
  % --- Frame ---
  %
  draw (0,0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
  %  
  % --- LaTex counter i=0,...,15
  %
  label(btex 
          \itshape
	  i =
	  \whiledo{\value{i}<16}{%
	    \thei\ \stepcounter{i}	  
	  }%    
        etex rotated angle(breite, hoehe), .5(breite, hoehe)); 
  %  
  % --- LaTex counter i=16,...,19
  %
  label(btex 
          i = 16,...,19:
	  \whiledo{\value{i}<20}{%
	    $P_{\thei}$\hspace{.5em} \stepcounter{i}	  
	  }%    
        etex rotated -angle(breite, hoehe), .5(breite, hoehe)); 
  %	
  % --- Red polygon and knots ---
  %
  for k=0 upto 7:
    draw z[k]--z[(k+1)mod 8]              withcolor (1, .5, .5);
    fill fullcircle scaled 9 shifted z[k] withcolor (1, .5, .5);
  endfor	
  %
  % --- LaTeX counter j=0,...,8 (red circles) ---
  %	
  dotlabel.urt(btex $P_{\thej}(j=\thej)$ \stepcounter{j} etex, z[0]); 
  dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[1]); 
  dotlabel.urt(btex $P_{\thej}(j=\thej)$ \stepcounter{j} etex, z[2]); 
  dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[3]); 
  dotlabel.urt(btex $P_{\thej}(j=\thej)$ \stepcounter{j} etex, z[4]); 
  dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[5]); 
  dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[6]); 
  dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[7]); 
  %
  % --- LaTeX counter j is not stepped up! Keeps value j=8! (green circles) ---
  %  
  for k=0 upto 7:
    draw (z[k]--z[(k+1)mod 8])shifted (2v, 0)       withcolor (.5, 1, .5);
    fill fullcircle scaled 9 shifted (z[k]+(2v, 0)) withcolor (.5, 1, .5);
    dotlabel.urt(btex $P_{\thej}$ \stepcounter{j} etex, z[k]shifted (2v, 0)); 
  endfor
  %
  % --- Final value of j:
  %
  label.llft(btex $j=\thej$ etex, (breite, hoehe));  
  	    
  label.urt("latex2html 2002 - 1", (0,0)); label.ulft("30.09.2002", (breite, 0));
  label.lrt(btex Urs Oswald etex rotated -90, (0, hoehe));
endfig;

end