-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.ts
100 lines (87 loc) · 2.37 KB
/
index2.ts
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
import * as c from './console';
import { Turtle } from './turtle';
window.onload = c.wrapmain(main);
const input = c.input;
const print = c.print;
function fact(i): number {
let result = 1;
for (let j = 1; j <= i; j++)
result *= j;
return result;
}
async function main() {
let t = new Turtle();
t.toggleConsole();
t.liveMode = true;
// t.execute(`
// fd 100
// lt 90
// `);
//t.left(90);
//t.forward(100);
window['t'] = t;
//t.pos = t.corners.lower;
// let drawStar = (radius, callAtPoint = null) => {
// t.pushPos();
// t.penUp();
// t.left(90);
// t.forward(radius);
// t.left(360 * 2 / 5 - (180 - 360 * 2 / 5) * 2 + 180 + 90);
// t.penDown();
// for (let i = 0; i < 5; i++) {
// t.forward(radius * Math.sin(360 / 5 / 2) * 2);
// if (callAtPoint) callAtPoint();
// t.left(360 * 2 / 5);
// }
// t.popPos();
// };
// drawStar(100, () => drawStar(33, () => drawStar(11)));
// for (let i = 0; i < 360; i+=10) {
// t.forward(20);
// t.left(10);
// }
// for (let i = 0; i < 360; i += 10) {
// t.penThickness = 5;
// t.pos = t.corners.center;
// t.color = t.hsl(i*4);
// t.forward(100);
// t.pushPos();
// t.right(90);
// t.left(45);
// let side = 40;
// t.forward(side);
// t.left(90+45);
// t.forward(side * 2 / Math.sqrt(2));
// t.left(90+ 45);
// t.forward(side);
// t.popPos();
// t.left(10);
// await t.update(100);
// }
// t.pos = t.corners.left;
// t.color;
// for (let i = 0; i < 5; i++) {
// t.forward(100);
// t.left(360 * 2 / 5);
// }
// for (let j = 0; j < 36; j++) {
// //if (j % 2 == 0) t.penUp();
// //else t.penDown();
// //t.clear();
// t.color = t.hsl(j*10);
// t.penThickness = 10;
// for (let i = 0; i < 4; i++) {
// t.forward(100);
// t.left(90);
// }
// t.left(10);
// await t.update(100);
// }
// t.hide();
// let n = await input("Enter n: ");
// //print(fact(n));
// let a = [];
// for (let i = 1; i <= n; i++)
// a.push(await input(`Enter #${i}: `));
// print(a.reduce((a,b)=>a+b, 0));
}