Skip to content

Commit 225e132

Browse files
Courssumm02Courssumm02
authored andcommitted
M7
1 parent bb65240 commit 225e132

File tree

4 files changed

+15861
-0
lines changed

4 files changed

+15861
-0
lines changed

Module Extra 7/app.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Make an instance of two and place it on the page.
2+
var elem = document.getElementById('draw-shapes');
3+
var params = { width: 500, height: 200, fullscreen: true };
4+
var two = new Two(params).appendTo(elem);
5+
6+
7+
8+
var frame_objects=[]
9+
var all_connecters=[]
10+
var all_tops=[]
11+
var all_bottoms=[]
12+
var len = 300
13+
for (let i = 0; i < len; i++){
14+
var pos_x = -len+i*30
15+
var x = Math.PI/2*i/3
16+
var dist = 80
17+
var up = Math.round(Math.sin(x)*dist)
18+
var down = -Math.round(Math.sin(x)*dist)
19+
var connecter = two.makeRectangle(pos_x,300,10,up*2)
20+
connecter.fill="lightgray"
21+
connecter.stroke="gray"
22+
connecter.linewidth=3
23+
var size1 = 10//(up/40 + 10)/1
24+
var size2 = 10//(down/40 + 10)/1
25+
var circle_top = two.makeCircle(pos_x, 300 + up, size1)
26+
circle_top.fill = "red"
27+
circle_top.stroke = "darkred"
28+
circle_top.linewidth = 3
29+
var circle_bottom = two.makeCircle(pos_x, 300 + down, size2)
30+
circle_bottom.fill = "orange"
31+
circle_bottom.stroke = "#cc5500"
32+
circle_bottom.linewidth = 3
33+
// frame_objects.push(connecter, circle_top, circle_bottom)
34+
all_connecters.push(connecter)
35+
all_tops.push(circle_top)
36+
all_bottoms.push(circle_bottom)
37+
}
38+
// var group = two.makeGroup(frame_objects)
39+
40+
tops = two.makeGroup(all_tops)
41+
connecters = two.makeGroup(all_connecters)
42+
bottoms = two.makeGroup(all_bottoms)
43+
console.log(connecters.getBoundingClientRect());
44+
var n = 0
45+
var target=12
46+
two.bind('update', function(frameCount) {
47+
if (frameCount%20==0){
48+
// tops.translation.x+=n&target?30:-target*30
49+
// bottoms.translation.x+=n<target?30:-30*target
50+
// connecters.translation.x+=n<target?30:-30*target
51+
console.log(target);
52+
n++
53+
if (n==target){
54+
n=0
55+
}
56+
}
57+
}).play(); // Finally, start the animation loop
58+
59+
two.update();

Module Extra 7/main.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
<link rel="stylesheet" href="styles.css">
9+
<!-- <script src=" https://cdn.jsdelivr.net/npm/[email protected]/underscore-umd-min.js "></script> -->
10+
11+
<script src="two.js"></script>
12+
</head>
13+
<body>
14+
<div id="draw-shapes"></div>
15+
<script src="app.js"></script>
16+
</body>
17+
</html>

Module Extra 7/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
html, body {
2+
height:100%;
3+
width:100%;
4+
margin:0;
5+
padding:0;
6+
}

0 commit comments

Comments
 (0)