forked from dezmou/CryptoGPU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·57 lines (51 loc) · 1.68 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
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="webApp.js"></script>
<style>
#mainCanvas{
border : 1px solid black;
}
</style>
</head>
<body>
<h1 id="test"></h1>
<div id='top'>
</div>
<div id="canvas">
<canvas id="mainCanvas" width="5000" height="900"></canvas>
</div>
<script>
const DATA_TYPE_CLEAR = 0;
const DATA_TYPE_LINES = 1;
const X = 0;
const Y = 1;
let data;
let c=document.getElementById("mainCanvas");
let ctx=c.getContext("2d");
const parseData = () => {
for (dat of data){
if (dat.type === DATA_TYPE_LINES){
ctx.beginPath();
ctx.moveTo(dat.points[0][X], dat.points[0][Y])
dat.points.shift();
for (point of dat.points){
ctx.lineWidth = 3;
ctx.lineTo(point[X], point[Y]);
}
ctx.strokeStyle = dat.color;
ctx.stroke();
ctx.closePath();
}else if(dat.type === DATA_TYPE_CLEAR){
ctx.clearRect(0,0,5000,900)
}
}
}
const refresh = (param) => {
data = JSON.parse(param);
parseData();
}
connectServer(refresh);
</script>
</body>
</html>