-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun Ball.html
More file actions
78 lines (64 loc) · 1.36 KB
/
Fun Ball.html
File metadata and controls
78 lines (64 loc) · 1.36 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fun Ball</title>
<script type="text/javascript" src="paper-full.js">
</script>
<script type="text/paperscript" canvas="myCanvas">
var path = new Path.Circle({
center: view.center,
radius: 40,
fillColor: 'red'
});
var destination = Point.random() + 40 ;
function onFrame(event) {
var vector = destination - path.position;
path.position += vector/30;
if (vector.length < 80) {
destination = Point.random() * view.size;
}
path.fillColor.hue += 1;
}
</script>
<style type="text/css">
#myCanvas{
background: rgba(128,128,128,0.5);
width:50%;
margin-left: 300px;
margin-top: 50px;
}
#header1{
margin-top: 50px;
margin-left: 500px;
}
#header2{
color: black;
margin-left: 650px;
}
body{
background: rgba(0,0,255,0.3);
}
</style>
</head>
<body >
<h1 id="header1">Moving and Color changing</h1>
<h1 id="header2">Ball</h1>
<canvas id="myCanvas" resize></canvas>
<script type="text/javascript" >
var h=document.querySelector("body");
var i;
var ar=["rgba(0,255,0,0.5)","rgba(0,0,255,0.5)","rgba(255,0,0,0.5)"];
function jsHello(i) {
if (i===0){
jsHello(3);
}
setTimeout(function () {
h.style.background=ar[i];
jsHello(--i);
}, 1500);
}
jsHello(2);
</script>
</body>
</html>