File: mpost.mp

package info (click to toggle)
mlpost 0.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,844 kB
  • sloc: ml: 21,094; javascript: 4,047; makefile: 430; ansic: 34; lisp: 19; sh: 15
file content (198 lines) | stat: -rw-r--r-- 4,448 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
input boxes;

beginfig(1)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    draw A--B--C;
endfig;

beginfig(2)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    draw A--B--C--cycle;
  
endfig;

beginfig(4)
    pair A;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    draw A withpen pencircle scaled 4bp;
endfig;

beginfig(5)
  pair A, B, C;
  A:=(0,0); B:=(1cm,0); C:=(0,1cm);
  draw A--B--C--cycle;
  draw A withpen pencircle scaled 4bp;
  draw B withpen pencircle scaled 4bp;
  draw C withpen pencircle scaled 4bp;
endfig;

beginfig(7)
  pair A, B, C;
  A:=(0,0); B:=(1cm,0); C:=(0,1cm);
  draw A--B--C--cycle;
  draw 1/2[A,B] -- C;
  draw 1/2[B,C] -- A;
  draw 1/2[C,A] -- B;
endfig;

beginfig(12)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    draw A--B withpen pencircle scaled 2bp withcolor .8white;
    draw B--C withpen pencircle scaled 2bp withcolor .6white;
    draw C--A withpen pencircle scaled 2bp withcolor .4white;
endfig;

beginfig(20)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    fill A--B--C--cycle withcolor .8 white;
endfig;

beginfig(21)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    fill A--B--C--cycle withcolor .8 white;
    draw A--B--C--cycle;  
endfig;

beginfig(22)
  pair A, B, C;
  A:=(0,0); B:=(1cm,0); C:=(0,1cm);
  fill A--B--C--cycle withcolor .8 white;
  draw A--B--C--cycle withpen pencircle scaled 2bp;
endfig;

beginfig(23)
  pair A, B, C;
  A:=(0,0); B:=(1cm,0); C:=(0,1cm);
  draw A--B--C--cycle withpen pencircle scaled 2bp;
  fill A--B--C--cycle withcolor .8 white;
endfig;

beginfig(60)
    u:=.5cm;
    pair A,B,C,D;
    A:=(0,0);   B:=(-u,2u);
    C:=(4u,3u); D:=(3u,0);
    draw A.. controls B and C .. D
         withpen pencircle scaled 2pt;
%    draw B--C dashed evenly;
    draw B--C withcolor .8 white;
    drawarrow A--B;
    drawarrow D--C;
  
endfig;

beginfig(111)
  path a,b,c;
  a = fullcircle scaled 2cm shifted (.5cm,0);
  b = a rotated (360/3);
  c = b rotated (360/3);
  fill a withcolor red;
  fill b withcolor green;
  fill c withcolor blue;
  fill buildcycle(a,b) withcolor red + green;
  fill buildcycle(b,c) withcolor green + blue;
  fill buildcycle(c,a) withcolor blue + red;
  fill buildcycle(a,b,c) withcolor white;
  draw a; draw b; draw c;
endfig;

beginfig(130)
  transform T;
  u:=1cm;
  z0=(0,0); z1=(2u,0); z3 = z1 rotated 90; z2 = z1+z3;
  z0 transformed T = .1[z0,z1];
  z1 transformed T = .1[z1,z2];
  z2 transformed T = .1[z2,z3];
  path p;
  p = z0--z1--z2--z3--cycle;
  for i=0 upto 50:
    fill p withcolor .8*white;
    p := p transformed T;
    fill p withcolor white;
    p := p transformed T;
  endfor;
endfig;

beginfig(140)
  for i=1 step -.01 until 0:
    fill fullcircle scaled (i*2cm) withcolor i*white;
  endfor;
  draw fullcircle scaled 2cm withpen pencircle scaled 2bp;
endfig;

% beginfig(141)
%   u:=5mm;
%   path p;
%   p = (0,0) .. (-1,1) .. (2,0) .. (0,-3) .. cycle;
%   p := p shifted (-1,0);
%   for i=1 step -.01 until 0:
%     fill p scaled (i*u) withcolor i*white;
%   endfor;
%   draw p scaled u withpen pencircle scaled 2bp;
% endfig;

beginfig(149)
  def couleur(expr x) =
    if x>.5: (2*(1-x)) [red, blue];
    else:    (1-2x) [blue, red]
    fi
  enddef;
  for i=0 step .5 until 360:
    draw 2cm* (sind(2*i), cosd(3*i))
    withpen pencircle scaled 2bp
    withcolor couleur(i/360);
  endfor;
endfig;

beginfig(195)
  n:=8;
  u:=5mm;
  for i=0 upto n-1:
    for j=0 upto n-1:
      if odd(i+j):
        for k=0 step u/5 until 4/5 u:
          if odd(k*5/u):
            fill ( (k,0)--(u,u-k)--(u,u-k-u/5)--
                   (k+u/5,0)--cycle )
                 shifted (i*u,j*u) withcolor .8white;
          else:
            fill ( (0,k)--(u-k,u)--(u-k-u/5,u)--
                   (0,k+u/5)--cycle )
                 shifted (i*u,j*u) withcolor .8white;
          fi;
        endfor;
      fi;
    endfor;
  endfor;
  for i=0 upto n:
    draw (0,i*u)--(n*u,i*u);
    draw (i*u,0)--(i*u,n*u);
  endfor;
endfig;

beginfig(267)
  def drawredboxed(text t) =
    forsuffixes a=t:
      fill bpath a withcolor .5[red,white];
    endfor;
    drawboxed(t);
  enddef;

  circleit.a(btex D\'ebut etex);
  a.c = (0,0);
  a.dx = a.dy;
  circleit.b(btex Fin etex);
  b.c = (2cm,0);
  b.dx = b.dy;
  drawredboxed(a,b);
  drawarrow  a.c {dir 45} .. b.c {dir -45}
  cutbefore bpath.a cutafter bpath.b;
  drawarrow  b.c {dir -135} .. a.c {dir 135}
  cutbefore bpath.b cutafter bpath.a;
  
endfig;