-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
97 lines (89 loc) · 1.85 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Canvas Flyline</title>
<style>
*{
margin:0px;
box-sizing: border-box;
}
html,body{
height: 100%;
}
#main{
width: 100%;
height: 100%;
overflow:hidden;
background: black;
}
#canvas{
position: absolute;
cursor: crosshair;
}
#controls{
border:2px red solid;
position: absolute;
z-index: 9;
background: #fff;
padding: 20px;
}
</style>
</head>
<body>
<div id="main">
<div id="controls">
<button id="line">line</button>
<br><br><br>
<button id="quard">quard</button>
</div>
<canvas id="canvas">
</canvas>
</div>
<script>
window.onload = function(){
var canvas = document.querySelector("#canvas");
canvas.width = document.querySelector("#main").clientWidth;
canvas.height = document.querySelector("#main").clientHeight;
var w = canvas.width,
h = canvas.height;
flyline.setCanvas("#canvas");
document.getElementById('line').addEventListener("click",addL)
document.getElementById('quard').addEventListener("click",addQ)
function addL(){
var o = {
start:{
x:Math.random()*w,
y:Math.random()*h
},target:{
x:Math.random()*w,
y:Math.random()*h
},color:'#'+('00000'+(Math.random()*0x1000000<<0).toString(16)).substr(-6),
time:5000*Math.random(),
len:1,
size:5
}
flyline.addFlyL(o)
}
function addQ(){
var o = {
start:{
x:Math.random()*w,
y:Math.random()*h
},target:{
x:Math.random()*w,
y:Math.random()*h
},color:'#'+('00000'+(Math.random()*0x1000000<<0).toString(16)).substr(-6),
time:5000*Math.random(),
len:1,
size:5,
i:Math.random()*2-1
}
flyline.addFlyQ(o);
}
}
</script>
<script src="./stats.js"></script>
<script src="./src/flyline.js"></script>
</body>
</html>