-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
146 lines (133 loc) · 3.77 KB
/
Copy pathindex.html
File metadata and controls
146 lines (133 loc) · 3.77 KB
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
<!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">
<title>Gravity-Example</title>
<style>
canvas {
background-color: #4c5a70;
margin: auto;
padding: 10px;
}
#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: #4c5a70;
padding: 0;
margin: 0;
}
.slider-range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #2c3e50;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.slider-range::-webkit-slider-thumb:hover {
background: #4c5a70;
}
.slider-range:active::-webkit-slider-thumb {
background: #4c5a70;
}
.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: #4c5a70;
}
.slider-range:active::-moz-range-thumb {
background: #4c5a70;
}
.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;
}
.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: #d7dcdf;
border: 0;
}
input::-moz-focus-inner,
input::-moz-focus-outer {
border: 0;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="input" align="center">
<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>
<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.2" min="0.1" max="1">
<span class="slider-value">0.2</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="25" min="1" max="50">
<span class="slider-value">25</span>
</div>
</div>
<script src="gravity.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>