Debian Codegraph @

texmf-dist/doc/metapost/mpattern/test.mp

raw
1 input mpattern;
2 prologues:=1;
3
4 beginpattern(szachy_i);
5 patterncolor(.8);
6 fill unitsquare scaled 4mm;
7 fill unitsquare scaled 4mm shifted (4mm,4mm);
8 endpattern;
9
10 beginpattern(szachy_ii);
11 fill unitsquare scaled 3mm withcolor .7white;
12 fill unitsquare scaled 3mm shifted (3mm,3mm) withcolor .7white;
13 endpattern;
14
15 beginfig(1);
16 fill fullcircle scaled 30mm withpattern szachy_i;
17
18 picture q;
19 q:=currentpicture; clearit;
20
21 draw q shifted (10mm*right) rotated 30 scaled .5;
22
23 fill unitsquare scaled 20mm withpattern szachy_ii;
24 endfig;
25
26 beginpattern(checker);
27 u:=1mm;
28 fill unitsquare scaled u;
29 fill unitsquare scaled u shifted (u,u);
30 patternbbox(0,0,2u,2u);
31 patterntransform(identity slanted .17);
32 endpattern;
33
34 beginpattern(rotated_checker);
35 fill unitsquare scaled 4mm rotated 45 withcolor .7white;
36 patterntransform(identity rotated 30);
37 endpattern;
38
39 beginfig(11);
40 path p;
41 z1=(1cm,1cm);
42 p=fullcircle scaled 3cm;
43 fill p withpattern checker;
44 unfill p shifted z1;
45 fill p shifted z1 withpattern rotated_checker;
46 endfig;
47
48 beginpattern(tt);
49 fill unitsquare scaled 2mm rotated 45 withcolor .5white;
50 z1=llcorner currentpicture;
51 z2=lrcorner currentpicture;
52 z3=urcorner currentpicture;
53 z4=ulcorner currentpicture;
54 % draw z1--z2--z3--z4--cycle;
55 patterntransform(identity rotated 30 slanted .2 yscaled 3);
56 patternstep((1.1*xpart(urcorner currentpicture-ulcorner currentpicture),
57 2/3*xpart(urcorner currentpicture-ulcorner currentpicture)));
58 endpattern;
59
60 beginpattern(ttt);
61 fill unitsquare scaled 2mm rotated 45 withcolor .5white;
62 z1=llcorner currentpicture;
63 z2=lrcorner currentpicture;
64 z3=urcorner currentpicture;
65 z4=ulcorner currentpicture;
66 % draw z1--z2--z3--z4--cycle;
67 patterntransform(identity rotated 30 slanted .2);
68 patternstep((1.1*xpart(urcorner currentpicture-ulcorner currentpicture),
69 2/3*xpart(urcorner currentpicture-ulcorner currentpicture)));
70 endpattern;
71
72 beginpattern(tr);
73 u:=4mm;
74 z1=(0,0);
75 z2=(u,0);
76 z3=(u,2u);
77 z4=(0,2u);
78 z12=.5[z1,z2];
79 z23=.5[z2,z3];
80 z34=.5[z3,z4];
81 z41=.5[z4,z1];
82 draw z12--z23--z34--z41--cycle;
83 draw z23--z41;
84 draw z1--z2;
85 draw z3--z4;
86 patternbbox(z1,z3);
87 patterntransform(identity slanted .1 rotated 11);
88 patternstep(1.2(x2-x1),1.2(y3-y1));
89 endpattern;
90
91 beginfig(12);
92 path p;
93 z1=(1cm,1cm);
94 p=fullcircle scaled 3cm;
95 fill p withpattern tt;
96 draw p;
97 unfill p shifted z1;
98 fill p shifted z1 withpattern tr;
99 draw p shifted z1;
100 endfig;
101
102 beginpattern(ll);
103 pickup pencircle scaled .3;
104 draw origin--4up;
105 patternbbox(left,4up+right);
106 patterntransform(identity rotated -45);
107 endpattern;
108
109 beginpattern(lll);
110 pickup pencircle scaled .3;
111 draw origin--4up;
112 patternbbox(left,4up+right);
113 patterntransform(identity rotated 45);
114 endpattern;
115
116 beginpattern(literki);
117 label(btex \font\q=ptmr8r at 5pt\q abcd etex,origin);
118 z1=ulcorner currentpicture;
119 z2=urcorner currentpicture;
120 patterntransform(identity slanted .17);
121 endpattern;
122
123 beginpattern(cm_literki);
124 label(btex \font\q=cmr5\q xyz XYZ ZYX zyx etex,origin);
125 z1=ulcorner currentpicture;
126 z2=urcorner currentpicture;
127 patterntransform(identity slanted .17);
128 endpattern;
129
130 beginfig(13);
131 label(btex \font\q=ptmr8r at 90pt\q ABCD etex, origin) withpattern ll;
132 endfig;
133
134 beginfig(14);
135 picture a; a=btex \font\q=ptmbi8r at 90pt\q ABCD etex;
136 draw a withpattern literki;
137 undraw a shifted (20up+10right);
138 draw a shifted (20up+10right) withpattern checker;
139 undraw a shifted (40up+20right);
140 draw a shifted (40up+20right) withpattern lll;
141 draw a shifted (40up+20right) withpattern ll;
142 undraw a shifted (60up+30right);
143 draw a shifted (60up+30right) withpattern cm_literki;
144 endfig;
145
146 end.