-
Notifications
You must be signed in to change notification settings - Fork 0
/
example3.html
95 lines (75 loc) · 2.72 KB
/
example3.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shared Windows ver:3.0</title>
<script src="./sharedwnd.js"></script>
<style>
* { margin: 0; padding: 0;}
body, html { height:100%; overflow: hidden;}
body {
width: 500 px;
height: 500 px;
}
#out {
background-color: black;
}
</style>
</head>
<body>
<canvas id="out" width="1920" height="1080"></canvas>
<script>
window.onload = function() {
initSharedWnd();
}
window.onunload = function() {
clearSharedWnd();
}
const drawParticle = (ctx,x,y,rx,ry,c) => {
ctx.fillStyle = c;
let fx,fy;
for(let fi = 0;fi<5*6.28;fi+=0.01)
{
rx += .3*(Math.random()-0.5);
ry += .3*(Math.random()-0.5);
fx = x+rx*Math.sin(fi);
fy = y+ry*Math.cos(fi);
fx += 30*(Math.random()-0.5);
fy += 30*(Math.random()-0.5);
ctx.fillRect(Math.floor(fx), Math.floor(fy), 1, 1);
}
}
let ctx = document.getElementById("out").getContext("2d");
const colors = [
'#ff0000',
'#00ff00',
'#0000ff',
'#00ffff',
'#ff00ff',
'#ffff00'
];
let ncolors = colors.length;
var interval = setInterval(function() {
if(localStorage.getItem("shwndid")) {
let shwndid = parseInt(sessionStorage.getItem("shwndid"));
let info = window.screenX+","+window.screenY+","+window.innerWidth+","+window.innerHeight;
localStorage.setItem("shwndid"+shwndid,info);
let ls = localStorage.getItem("shwndid");
let arr = ls.split(",");
let num = arr.length;
ctx.clearRect(0, 0,1920,1080);
ctx.font = "10px Arial";
ctx.fillText(num, 10, 10);
let j = 0;
for(let i in arr) {
let hwnds = localStorage.getItem("shwndid"+arr[i]);
let ahwnds = hwnds.split(",");
drawParticle(ctx,ahwnds[0]-window.screenX+window.innerWidth/2, ahwnds[1]-window.screenY+window.innerHeight/2,150,150,colors[j%ncolors]);
j++;
}
}
}, 25);
</script>
</body>
</html>