Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/manjusha.mp

raw
1
2 numeric u;
3 u = 1cm;
4 pen thin, thick;
5 thin = pencircle scaled 1pt;
6 thick= pencircle scaled 3pt;
7
8 verbatimtex
9 \documentclass{article}
10 \usepackage{palatino}
11 \begin{document}
12 etex
13
14 beginfig(1);
15 pair a, b, c, d;
16 a = origin;
17 b = (1u,2u);
18 c = (4u,2u);
19 d = (6u,0);
20 path lines, curve;
21 lines = a--b--c--d;
22 curve = a..controls b and c..d; %%%%%%%%%%% This is quite powerfull.
23 draw lines withpen thin withcolor red+blue;
24 draw curve withpen thin withcolor blue;
25 drawoptions( withpen thick );
26 draw a;
27 draw b;
28 draw c;
29 draw d;
30 endfig;
31
32 beginfig(4);
33 pair a, b, c, d, e;
34 a = origin;
35 b = (2.5u,0.5u);
36 c = (4u,2u);
37 d = (6u,0);
38 e = (4u,-0.5u);
39 drawoptions( withcolor blue );
40 picture thecaption;
41 thecaption = btex Degree 3 etex;
42 label( thecaption, e );
43 path lines, curve;
44 lines = a--b--c--d;
45 curve = a..controls b and c..d;
46 draw lines withpen thin withcolor red+blue;
47 draw curve withpen thin withcolor blue;
48 drawoptions( withpen thick withcolor red+green );
49 draw a;
50 draw b;
51 draw c;
52 draw d;
53 endfig;
54
55 beginfig(6);
56 numeric n, i;
57 n = 100;
58 pair p[];
59 for i=1 upto n:
60 p[i] = (uniformdeviate(4u),uniformdeviate(3u));
61 draw p[i] withpen thick withcolor green;
62 endfor;
63 path everywhere, convexhull;
64 everywhere = p1 for i=2 upto n: --p[i] endfor --cycle;
65 convexhull = makepath makepen everywhere; %%%%%%%%%%%%%% Wow!
66 draw convexhull withpen thin withcolor red+green;
67 for i=1 upto length convexhull:
68 draw point i of convexhull withpen thick withcolor blue;
69 endfor;
70 endfig;
71
72 verbatimtex
73 \end{document}
74 etex
75
76 end.