% In development

\def\multlength#1#2{\multiply#1 by #2\relax}
\def\divlength#1#2{\divide#1 by #2\relax}

\makeatletter

\def\multcounter#1#2{\@ifundefined{c@#1}{\@nocnterr}%
{\global\multiply\csname c@#1\endcsname by #2\relax}}

\def\divcounter#1#2{\@ifundefined{c@#1}{\@nocnterr}%
{\global\divide\csname c@#1\endcsname by #2\relax}}

\newcommand{\showcounter}[1]% for debugging 
{\def\showtemp{\csname c@#1\endcsname}\showthe\showtemp}

\makeatother

\newcounter{divisions}
\newcounter{xcoarse}\newcounter{ycoarse}
\newcounter{xfine}\newcounter{yfine}
\newcounter{pdlinex}

\comm{
\def\grid(#1,#2){\setcounter{xcoarse}{#1}\setcounter{ycoarse}{#2}%
\setcounter{xfine}{#1}\setcounter{yfine}{#2}%
\multcounter{xfine}{\value{divisions}}\multcounter{yfine}{\value{divisions}}%
\divlength{\unitlength}{\value{divisions}}%
\begin{picture}(\value{xfine},\value{yfine})
 \addtocounter{xcoarse}{1}\addtocounter{yfine}{1}
 \addtocounter{xfine}{1}\addtocounter{ycoarse}{1}
 \arrayputs(0,0)(\value{divisions},1)%
{\value{xcoarse}}{\value{yfine}}{\makebox(0,0){.}}
 \arrayputs(0,0)(1,\value{divisions})%
{\value{xfine}}{\value{ycoarse}}{\makebox(0,0){.}}
 \end{picture}%
}
}

\def\grid(#1,#2){\setcounter{xcoarse}{#1}\setcounter{ycoarse}{#2}%
\addtocounter{xcoarse}{1}\addtocounter{ycoarse}{1}%
\arrayputs(0,0)(1,1){\value{xcoarse}}{\value{ycoarse}}{\makebox(0,0){.}}}

\def\metal(#1,#2){\setcounter{xfine}{#1}\setcounter{yfine}{#2}%
\multcounter{xfine}{\value{divisions}}\multcounter{yfine}{\value{divisions}}%
\divlength{\unitlength}{\value{divisions}}%
\begin{picture}(\value{xfine},\value{yfine})
 \addtocounter{xfine}{1}
 \multiput(0,0)(1,0){\value{xfine}}{\line(0,1){\value{yfine}}}
 \end{picture}%
}

 \def\pdlines(#1)(#2)#3(#4){\setcounter{pdlinex}{#3}%
\multiput(#1)(#2){#3}{\pdline(#4)}
}
\def\pdline(#1,#2){\line(#1,#2){\value{pdlinex}}\addtocounter{pdlinex}{-1}}

 \def\polyvert(#1,#2){\setcounter{xfine}{#1}\setcounter{yfine}{#2}%
\multcounter{xfine}{\value{divisions}}\multcounter{yfine}{\value{divisions}}%
\divlength{\unitlength}{\value{divisions}}%
\begin{picture}(\value{xfine},\value{yfine})
 \pdlines(0,0)(1,0){\value{xfine}}(1,1)
 \pdlines(\value{xfine},\value{yfine})(-1,0){\value{xfine}}(-1,-1)
 \addtocounter{yfine}{-\value{xfine}}
 \multiput(0,0)(0,1){\value{yfine}}{\line(1,1){\value{xfine}}}
 \end{picture}%
}

 \def\diffvert(#1,#2){\setcounter{xfine}{#1}\setcounter{yfine}{#2}%
\multcounter{xfine}{\value{divisions}}\multcounter{yfine}{\value{divisions}}%
\divlength{\unitlength}{\value{divisions}}%
\begin{picture}(\value{xfine},\value{yfine})
 \pdlines(\value{xfine},0)(-1,0){\value{xfine}}(-1,1)
 \pdlines(0,\value{yfine})(1,0){\value{xfine}}(1,-1)
 \addtocounter{yfine}{-\value{xfine}}
 \multiput(\value{xfine},0)(0,1){\value{yfine}}{\line(-1,1){\value{xfine}}}
 \end{picture}%
}
 \def\diffhor(#1,#2){\setcounter{xfine}{#1}\setcounter{yfine}{#2}%
\multcounter{xfine}{\value{divisions}}\multcounter{yfine}{\value{divisions}}%
\divlength{\unitlength}{\value{divisions}}%
\begin{picture}(\value{xfine},\value{yfine})
 \pdlines(\value{yfine},0)(-1,0){\value{yfine}}(-1,1)
 \pdlines(\value{xfine},0)(0,1){\value{yfine}}(-1,1)
 \addtocounter{xfine}{-\value{yfine}}
 \multiput(\value{yfine},0)(1,0){\value{xfine}}{\line(-1,1){\value{yfine}}}
 \end{picture}%
}

\newcommand{\via}{{\thicklines
  \put(0,0){\framebox(2,2){}}
  \multiput(-.025,0)(.025,0){3}{\line(1,1){2}}
  \multiput(2.025,0)(-.025,0){3}{\line(-1,1){2}}}}
