-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.html
151 lines (143 loc) · 4.06 KB
/
main.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<html>
<head>
<title>Gravity Toy</title>
<script src="Gravity.min.js"></script>
<script src="Particle.min.js"></script>
<style>
body {
color: #ffffff;
font-family: Courier New;
font-size: 11px;
}
button {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0px;
font-family: Courier New;
color: #ffffff;
font-size: 11px;
background: #000000;
padding: 5px 5px 5px 5px;
border: solid #ffffff 1px;
text-decoration: none;
width: 88px;
margin-top:2px;
}
.txt {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0px;
font-family: Courier New;
color: #ffffff;
font-size: 11px;
background: #000000;
padding: 5px 5px 5px 5px;
border: solid #ffffff 1px;
text-decoration: none;
margin-left:5px;
}
button:hover {
background: #ffffff;
color: #000000;
text-decoration: none;
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#controlbox {
padding:5px;
padding-left:20px;
margin-left:-20px;
border: solid #ffffff 1px;
border-left-width: 0px;
width:88px;
}
#homebox {
font-size:20px;
position:absolute;
right:10px;
top:0px;
padding:5px;
padding-top:10px;
margin-top:-10px;
padding-right:10px;
margin-right:-10px;
padding-left:10px;
border:solid #ffffff 1px;
border-right-width:0px;
}
a:link {
color:#0080FF;
}
a:visited {
color:#0000FF;
}
</style>
<script>
var interval = -1;
var newParticleSize = 100;
function start(){
if(interval == -1){
interval = window.setInterval("main();",30);
}
}
function stop(){
clearInterval(interval);
interval = -1;
}
function generateProto(){
for (var i = 0; i < 500; i++){
var rand = Math.random()*2*Math.PI;
var rand2 = Math.random();
var x = (100*rand2)*Math.cos(rand);
var y = (100*rand2)*Math.sin(rand);
var mag = Math.sqrt(x*x+y*y);
var particle = new Particle(1000, width/2+x, height/2+y, y*(mag/70), -x*(mag/70));
particleList.push(particle);
}
}
function setSize(size){
document.getElementById("mass").value=size.toExponential(1).replace("+","");
setNewMass(size);
}
function clearCanvas(){
particleList = [];
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61036065-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body onload = "init();start();" style="background-color:black">
<div class="noselect">
Inspired by the classic <a href="http://www.nowykurier.com/toys/gravity/gravity.html">Gravity Toy</a> and rewritten in Javascript.</br>
Click and drag to add new particles. Hold shift and drag to translate.</br></br>
<div id="controlbox" style="z-index:4">
<table>
<tr>Mass:<input type="text" value="1.0e3" class="txt" style="width:50px;" id="mass"></tr></br>
<tr><button onclick="setSize(100)">Tiny</button></tr></br>
<tr><button onclick="setSize(1000)">Small</button></tr></br>
<tr><button onclick="setSize(10000)">Medium</button></tr></br>
<tr><button onclick="setSize(100000)">Huge</button></tr></br>
<tr><button onclick="setSize(1000000)">Enormous</button></tr>
</table>
<button onclick="start()">Start</button></br>
<button onclick="stop()">Stop</button></br>
<button onclick="generateProto()">Protodisk</button></br>
<button onclick="clearCanvas()">Clear</button></br>
</div>
</div>
<canvas id="canvas" style="z-index:-1;position:absolute;left: 0px;top: 0px;"></canvas>
<div id="homebox"><a href='/'>Home</a></div>
</body>
</html>