% This file:
%   http://angg.twu.net/dednat5/tests/test2.tex.html
%   http://angg.twu.net/dednat5/tests/test2.tex
%                (find-dn5file "tests/test2.tex")
% Author: Eduardo Ochs <eduardoochs@gmail.com>
% Version: 2011apr22
% License: GPL3
%
% To compile this file and display the result I use this:
%   (defun c () (interactive) (find-sh "make test2.veryclean && make test2.pdf"))
%   (defun d () (interactive) (find-xpdfpage "~/dednat5/tests/test2.pdf"))
% See:
%   (find-dn5 "tests/Makefile" "test1")
%   http://angg.twu.net/dednat5/tests/test1.pdf

% «.metapost-head»	(to "metapost-head")
% «.metapost-library»	(to "metapost-library")
% «.metapost-diagram»	(to "metapost-diagram")


\documentclass{article}
\usepackage{graphicx}
\input test2.dnt % (find-fline "test2.dnt")
\begin{document}

% «metapost-head»  (to ".metapost-head")
%% (find-dn5 "diagforth.lua" "diag-head")
%L mplines = Stack {}
%L registerhead "%M" {
%L   action = function ()
%L       mplines:push(untabify(linestr):sub(4))
%L     end,
%L }
%M % Produced by: (find-dn5 "tests/test2.tex")
%M outputtemplate := "test2/%3c.mps";
\def\mpdiag#1{\includegraphics[scale=1.0]{test2/#1.mps}}
%L endmp = function ()
%L     writefile("test2.mp", table.concat(mplines, "\n").."\n")
%L   end

%M % «metapost-library»  (to ".metapost-library")
%M % (find-angg ".emacs.papers" "metapost")
%M % (find-angg "METAPOST/test1.mp")
%M % (find-angg "METAPOST/test1.tex")
%M def drawcircledot := addto currentpicture contour makepath pencircle enddef;
%M def drawpencircleat (expr s, p) := drawcircledot scaled s shifted p enddef;
%M def drawcdot expr p := drawpencircleat (3pt, p) enddef;
%M def drawbdot expr p := drawpencircleat (2pt, p) withcolor background enddef;
%M def drawodot expr p := drawcdot p; drawbdot p enddef;
%M
%M def startpoint expr p := point 0 of p enddef;
%M def endpoint   expr p := point (length p) of p enddef;
%M def drawcc_ expr p := drawcdot (startpoint p); drawcdot (endpoint p) enddef;
%M def drawco_ expr p := drawcdot (startpoint p); drawodot (endpoint p) enddef;
%M def drawoc_ expr p := drawodot (startpoint p); drawcdot (endpoint p) enddef;
%M def drawoo_ expr p := drawodot (startpoint p); drawodot (endpoint p) enddef;
%M def drawcc expr p := draw p; drawcc_ p enddef;
%M def drawco expr p := draw p; drawco_ p enddef;
%M def drawoc expr p := draw p; drawoc_ p enddef;
%M def drawoo expr p := draw p; drawoo_ p enddef;
%M
%M u := 0.5cm;
%M
%M pen axispen;
%M pen tickpen;
%M axispen := pencircle scaled 1pt;
%M tickpen := pencircle scaled 1pt;
%M tickradius := 3pt;
%M def Xaxis(expr xl, xr) :=
%M   drawarrow (xl*u, 0)--(xr*u, 0) withpen axispen;
%M   for x = (ceiling xl) upto (floor xr):
%M     draw (x*u, -tickradius)--(x*u, tickradius) withpen tickpen;
%M   endfor
%M enddef;
%M def Yaxis(expr yd, yu) :=
%M   drawarrow (0, yd*u)--(0, yu*u) withpen axispen;
%M   for y = (ceiling yd) upto (floor yu):
%M     draw (-tickradius, y*u)--(tickradius, y*u) withpen tickpen;
%M   endfor
%M enddef;
%M
%M def WIDTH expr w := pickup pencircle scaled w enddef;




A diagram (using MetaPost):
%M % «metapost-diagram»  (to ".metapost-diagram")
%M u := 0.5cm;
%M beginfig(1);
%M   Xaxis(-2, 3);
%M   Yaxis(-3, 4);
%M   drawcdot (1u, 1u);
%M   drawodot (2u, 1u);
%M   drawodot (2u, 2u);
%M   drawoc (0u,2u)--(2u,3u);
%M endfig;
$$\mpdiag{001}$$

%M end
%L endmp()





\end{document}



% Local Variables:
% coding:             raw-text-unix
% ee-anchor-format:   "«%s»"
% End:

