-
Notifications
You must be signed in to change notification settings - Fork 7
/
Template.html
382 lines (268 loc) · 10.3 KB
/
Template.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<html>
<head>
<title>Simulation Template.</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- Common Fonts I use. Calibri doesn't always work. -->
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Calibri:400,700,400italic,700italic" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Quattrocento+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway:100,200,300,400,500,600,700,800,900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Alegreya+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<!-- Some times used library for icons -->
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="icon" href="../square.png">
<style id='sliderstyles' type="text/css">
</style>
<style type="text/css">
:root {
--themeblue: hsla(196, 100%, 50%, 1);
--themeviolet: hsla(280, 100%, 50%, 1);
--themeorange: hsla(32, 100%, 50%, 1);
--boundaryorange: hsla(32, 100%, 50%, 0.6);
--themegrey: hsla(32, 0%, 70%, 0.6);
}
</style>
<style id="sliderStyleH" type="text/css">
a {
cursor: pointer;
}
.standardSlider {
-webkit-appearance: none;
border-radius: 5px;
outline: none;
-webkit-transition: .2s;
transition: opacity .2s;
}
.standardSlider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
border-radius: 50%;
background: hsla(200, 100%, 50%, 1);
cursor: pointer;
}
.standardSlider::-moz-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
border-radius: 50%;
background: hsla(200, 100%, 50%, 1);
cursor: pointer;
}
body::-webkit-scrollbar {
width: 5px;
}
body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
border-radius: 30px;
}
body::-webkit-scrollbar-thumb {
background-color: black;
border-radius: 50px;
/*outline: 1px solid slategrey;*/
}
</style>
<!-- Very important Library for handling layouts such as phone/tablet layouts. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="application/ld+json">
{
"@type": "Simulation",
"name": "Example Simulation Template",
"author": "Prajwal DSouza",
"description": "This is basic template for many simulations I make. It's not perfect and is still under development."
}
</script>
<meta charset="UTF-8">
<meta name="description" content="This is basic template for many simulations I make. It's not perfect and is still under development.">
<meta name="keywords" content="plots.js, prajwalsouza, Prajwal DSouza, template">
<meta name="author" content="Prajwal DSouza">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style='margin:0px; display: block;'>
<div id="containAll" style='margin:0px;width:100%; height: 100%; font-size: 0; display: inline-block; position: relative; '>
<div id="graphHolderH" style="display: inline-block; position: relative; width: 100%; height: 100%;"></div>
</div>
<script type="text/javascript">
// Not very important. But, useful for showing some useful information inside information displayer.
function infodisplay(infodata) {
document.getElementById('infoH').innerHTML = infodata
}
darkmode = false
if (darkmode) {
document.body.style.background = 'black'
}
</script>
<!-- A library/code I developed for most simulations. "plots.js" -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/prajwalsouza/prajwalsouza.github.io/JS/plots.js"></script>
<script type="text/javascript">
// The next two functions, can be important. But not always used.
// to handle dark mode
function setDarkMode() {
if (darkmode) {
darkmode = false
document.body.style.background = 'white'
document.getElementById('maintitle').style.color = 'hsla(190, 100%, 0%, 1)'
}
else {
document.body.style.background = 'black'
document.getElementById('maintitle').style.color = 'hsla(190, 100%, 100%, 1)'
}
}
// to handle phone/tablet/desktop layouts
function handleLayout1() {
if (dmode == 'landscape') {
document.getElementById('mainVSpacer1').style.width = '2%'
document.getElementById('MainBlock1').style.width = '48%'
document.getElementById('mainVSpacer2').style.width = '5%'
document.getElementById('MainBlock2').style.width = '43%'
document.getElementById('mainVSpacer3').style.width = '2%'
$('#plotGraphH').appendTo('#MainBlock1')
$('#mainB2HSpacer5').appendTo('#MainBlock1')
$('#parametersH').appendTo('#MainBlock1')
$('#mainB2HSpacer6').appendTo('#MainBlock1')
document.getElementById('maintitle').style.fontSize = '2vmax';
}
}
// handleLayout1()
// Main Code begins here.
animLoopCount = 0
calculationLoopCount = 0
// starts playing animations when the browser loads. Changing this on demand anywhere can pause animations.
playing = true
// plots object positions/movements/changes 30 times a second.
frameRate = 30
// calculates object positions/movements/changes 60 times a second.
// But I'll not be using this, this time.
// calculationRate = 60
frameInterval = 1000/frameRate
// calculationFrameInterval = 1000/calculationRate
// This is the importart part which sets up the graph.
function setUpGraph() {
graphH = document.getElementById('graphHolderH')
// Comment out whatever property you wanna use
graphoptions = {}
graphoptions.xmax = 10
graphoptions.xmin = -10
graphoptions.ymax = 10
graphoptions.ymin = -10
graphoptions.axislocationX = 0
graphoptions.axislocationY = 0
graphoptions.xaxislabelvisibility = 'no'
graphoptions.yaxislabelvisibility = 'no'
// graphoptions.xaxisvisibility= 'no'
// graphoptions.yaxisvisibility = 'no'
// graphoptions.xmajorgridlabelvisibility = 'no'
// graphoptions.ymajorgridlabelvisibility = 'no'
// graphoptions.xmajorgridlinesvisibility = 'no'
// graphoptions.ymajorgridlinesvisibility = 'no'
graphoptions.fontSize = 1.6
graphoptions.unitAspectRatio = 'yes'
graphoptions.fixAxisStretchCentrally = 'yes'
graphoptions.scrollZoom = 'yes'
graphoptions.draggability = 'yes'
addGraph(graphH, 'graphName', graphoptions)
// addGraph(div location inside which the graph gets added, graph name, parameters we described for the graph)
}
// We set up the graph
setUpGraph()
// Add objects to the graph called 'GraphName'
function addObjects() {
// We can add the following objects
// Adding a point at (5, 5)
options = {}
options.x = 5
options.y = 5
options.pointcolor = 'hsla(40, 100%, 50%, 1)' // Orange
options.pointsize = 1
addPoint('graphName', 'samplePoint', options)
// We will animate this later and move it in a circle of radius 3.
// Adding a path
options = {}
options.points = [[4, 0], [0, 4], [-4, 0], [0, -4], [4, 0]]
options.pathcolor = 'hsla(190, 100%, 50%, 1)' // Blue
options.strokewidth = 0.3
addPath('graphName', 'samplePath', options)
// Adding a circle at [3, 6] with radius 2
options = {}
options.x = 3
options.y = 6
options.radius = 2
options.circlecolor ='hsla(80, 100%, 50%, 0.4)' //lighter green
options.stroke = 'hsla(100, 100%, 50%, 1)' // green
options.strokewidth = 1
addCircle('graphName', 'sampleCircle', options)
// We'll change this radius and fill color continously later.
// Adding a line from [1, 1] to [3, 2]
options = {}
options.x1 = 1
options.y1 = 1
options.x2 = 3
options.y2 = 2
options.linecolor = 'hsla(280, 100%, 50%, 0.4)' // violet ish
options.strokewidth = 3
addLine('graphName', 'sampleLine', options)
// There are many more objects. Please check them out in the plots.js file.
}
addObjects()
// This is invoked inside the calculation loop. It calculates object positions.
// Not using this, this time.
function moveObjects() {
}
// This is invoked inside the animation loop. It plots object positions/changes.
function plotObjects() {
// animLoopCount increases by one every time step.
// We will update the position of the point at [5, 5] continously in a circle, at a radius of 3.
toMovePointX = 3*Math.cos(animLoopCount*0.01)
toMovePointY = 3*Math.sin(animLoopCount*0.01)
updatePointXY('graphName', 'samplePoint', toMovePointX, toMovePointY)
// We change the circle's radius in a oscillation.
newRadius = 2 + Math.cos(animLoopCount*0.01)
newColor = 'hsla(' + animLoopCount/2 + ', 100%, 50%, 0.4)'
// animLoopCount/2 goes from 0 to 349 changing colors.
options = {}
options.radius = newRadius
options.circlecolor = newColor
updateCircle('graphName', 'sampleCircle', options)
// To update other objects you can refer the plots.js file.
}
// Animation Handler
function playAnimationLoop(event) {
loopinterval = setInterval(frame, frameInterval);
function frame() {
animLoopCount = animLoopCount + 1
if (playing) {
plotObjects()
}
}
}
// Calculation Handler
// Not using it this time.
function playCalculationLoop(event) {
loopinterval2 = setInterval(frame, calculationFrameInterval);
function frame() {
calculationLoopCount = calculationLoopCount + 1
if (playing) {
plotObjects()
}
}
}
// playCalculationLoop()
// This will be use. This starts the animations.
playAnimationLoop()
// Important Code ends here.
// Not always used. But, helps, fix certain layout issues.
function handleLayout2() {
if (dmode == 'portrait') {
}
if (dmode == 'landscape') {
}
}
// handleLayout2()
</script>
</body>
<html>