From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 2 Sep 2019 13:46:59 +0900
Subject: Initial commit

---
 .../contrib/mpgraphics/mpgraphics-example.ltx      | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 macros/latex/contrib/mpgraphics/mpgraphics-example.ltx

(limited to 'macros/latex/contrib/mpgraphics/mpgraphics-example.ltx')

diff --git a/macros/latex/contrib/mpgraphics/mpgraphics-example.ltx b/macros/latex/contrib/mpgraphics/mpgraphics-example.ltx
new file mode 100644
index 0000000000..6b0d38150b
--- /dev/null
+++ b/macros/latex/contrib/mpgraphics/mpgraphics-example.ltx
@@ -0,0 +1,32 @@
+\documentclass{article}
+\usepackage{mpgraphics}
+\begin{document}
+\begin{mpdisplay}
+LaTeX_unitlength := 1.0pt;
+w := 60*LaTeX_unitlength;
+h := 40*LaTeX_unitlength;
+numeric xmin, xmax, ymin, ymax;
+xmin := 1/4; xmax := 6; ymax := 1/xmin; u := 1cm;
+vardef f(expr x) = 1/x enddef;
+xinc := 0.1;
+path pts_f;
+pts_f := (xmin,f(xmin))*u
+for x=xmin+xinc step xinc until xmax:
+.. (x,f(x))*u
+endfor;
+path hline[], vline[];
+hline0 = (0,0)*u -- (xmax,0)*u;
+vline0 = (0,0)*u -- (0,ymax)*u;
+vline0.5 = (0.5,0)*u -- (0.5,ymax)*u;
+vline4 = (4,0)*u -- (4,ymax)*u;
+fill buildcycle(hline0, vline0.5, pts_f, vline4)
+withcolor 0.8[blue,white];
+draw hline0; draw vline0; % draw axes
+draw (0.5,0)*u -- vline0.5 intersectionpoint pts_f;
+draw (4,0)*u -- vline4 intersectionpoint pts_f;
+draw pts_f withpen pencircle scaled 2;
+label.bot(btex $x$ etex, (0.9xmax,0)*u);
+label.lft(btex $y$ etex, (0,0.9ymax)*u);
+label.urt(btex Hello $f(x)$ etex, (0.5,f(0.5))*u);
+\end{mpdisplay}
+\end{document}
-- 
cgit v1.2.3

