-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsine_superposition.mdtlbl
More file actions
55 lines (44 loc) · 1.09 KB
/
sine_superposition.mdtlbl
File metadata and controls
55 lines (44 loc) · 1.09 KB
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
#**
* 简单的正弦波叠加可视化的有趣玩意
*#
take Builtin.BindSep['.'];
const Draw = (match @ => H {
const B=H->Binder;
draw linePoly B.x B.y 72 H.Range 0 0;
draw poly H.x H.y 72 2 0 0;
});
const Make = (match @ => Binder Range Speed {
const $.Binder = Binder;
const $.Range = Range;
const $.Run = ([H:$ B:Binder &Draw Range Speed](
H.x, H.y = cos(H.i)*Range, sin(H.i)*Range;
H.x, H.y += B.x, B.y;
H.i += Speed;
H.i %= 360;
take Draw[H];
));
const Binder.Run = ([&Run:Binder->Run Child:$](
take Run[] Child.Run[];
));
const $.Make = (setres Make[.. @];);
});
take Tail
= Make[start 20 1]
->Make[15 3]
->Make[10 7]
->Make[5 10];
start.x, start.y = 88;
i = 0;
do {
draw clear 0 0 0 0 0 0;
draw color 0xFF 0xFF 0xFF 0 0 0;
take start.Run[];
draw rect 0 Tail.y 176 1 0 0;
drawflush display1;
draw color 0 0 0 0 0 0;
draw rect i 0 1 176 0 0;
draw color 0xFF 0xFF 0xFF 0 0 0;
draw rect i Tail.y 1 1 0 0;
drawflush display2;
i++; i %= 176;
} while;