This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
176 lines (154 loc) · 4.98 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Gravity Simulator</title>
<style>
html,
body,
canvas {
background-color: #031635;
margin: 0;
padding: 0;
}
#input {
width: 100%;
margin: auto;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
.slider {
width: 40%;
padding-left: 3%;
}
.slider-range {
-webkit-appearance: none;
width: calc(100% - (73px));
height: 10px;
border-radius: 5px;
background: #000000;
padding: 0;
margin: 0;
}
.slider-range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #000000;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.slider-range::-webkit-slider-thumb:hover {
background: #000000;
}
.slider-range:active::-webkit-slider-thumb {
background: #FFFFFF;
}
.slider-range::-moz-range-thumb {
width: 20px;
height: 20px;
border: 0;
border-radius: 50%;
background: #2c3e50;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.slider-range::-moz-range-thumb:hover {
background: #2c3e50;
}
.slider-range:active::-moz-range-thumb {
background: #2c3e50;
}
.slider-value {
display: inline-block;
position: relative;
width: 60px;
color: #FFF;
line-height: 20px;
text-align: center;
border-radius: 3px;
background: #2c3e50;
padding: 5px 10px;
margin-left: 8px;
font-family: 'Open Sans', sans-serif;
font-size: 12px;
}
.slider-value:after {
position: absolute;
top: 8px;
left: -7px;
width: 0;
height: 0;
border-top: 7px solid transparent;
border-right: 7px solid #2c3e50;
border-bottom: 7px solid transparent;
content: '';
}
::-moz-range-track {
background: #000000;
border: 0;
}
input::-moz-focus-inner,
input::-moz-focus-outer {
border: 0;
}
label {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
color: #FFFFFF;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="info">
This is a gravity simulator, built to understand how celestial bodies warp the fabric of space-time and interact with each other.
Each particle represents a celestial body, and each line represents the gravitational force between two bodies.<br><br>
Adjust the sliders below to customise this galaxy <br><br><br>
</div>
<div id="input" align="center" style="width: 80%">
<label for="points">Gravitational Constant:</label>
<div class="slider">
<input class="slider-range" oninput="updateSliderValue(this)" onchange="reRunSim()" type="range" name="g" id="g" step="0.1" value="0.4" min="0.1" max="1">
<span class="slider-value">0.4</span>
</div>
<label for="points">Slowdown factor:</label>
<div class="slider">
<input class="slider-range" oninput="updateSliderValue(this)" onchange="reRunSim()" type="range" name="slowdown" id="slowdown" step="1" value="26" min="1" max="50">
<span class="slider-value">26</span>
</div>
<label for="points">Amount Of Objects:</label>
<div class="slider">
<input class="slider-range" oninput="updateSliderValue(this)" onchange="reRunSim()" type="range" name="objects" id="objects" step="1" value="100" min="25" max="100">
<span class="slider-value">100</span>
</div>
</div>
<div id="info" style="padding-left: 90%;">
Powered by <a href="https://www.github.com/abircb/gravity-simulator" style="color: #FFFFFF; text-decoration: underline;" target="_blank">GitHub</a>
</div>
<script src="g.min.js" charset="utf-8"></script>
<script>
init();
function updateSliderValue(temp) {
temp.nextElementSibling.innerHTML = temp.value;
}
function reRunSim() {
var objects = document.getElementById("objects").value;
var g = document.getElementById("g").value;
var slowDown = document.getElementById("slowdown").value;
init("canvas", [window.innerWidth - 20, window.innerHeight * 0.8], objects, g, slowDown, true);
}
</script>
</body>
</html>