Added the rest of the files
This commit is contained in:
198
7-2.html
Normal file
198
7-2.html
Normal file
@@ -0,0 +1,198 @@
|
||||
<!--
|
||||
This work is licensed under CC BY-NC-ND 4.0
|
||||
Link to license: http://creativecommons.org/licenses/by-nc-nd/4.0/
|
||||
Attribute to Russell Georgi
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Waves 7-2
|
||||
</title>
|
||||
<link rel="stylesheet" href="/rmg/waves7-2/style2.css" type="text/css">
|
||||
<style>
|
||||
.dropbtn {
|
||||
background-color: #04AA6D;
|
||||
color: white;
|
||||
padding: 16px;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
display: none;
|
||||
position: relative;
|
||||
background-color: #f1f1f1;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.dropdown-content button {
|
||||
color: black;
|
||||
padding: 12px 16px;
|
||||
width: 100px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdown-content a:hover {background-color: #ddd;}
|
||||
|
||||
.dropdown:hover .dropdown-content {display: block;}
|
||||
|
||||
.dropdown:hover .dropbtn {background-color: #3e8e41;}
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
}
|
||||
|
||||
canvas {
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="myCanvas" width="1" height="1" style="border:1px solid #ffffff;">
|
||||
Your browser does not support the HTML5 canvas tag.</canvas>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn" id="btn">kL = 0.5/π</button>
|
||||
<div class="dropdown-content">
|
||||
<button onclick="Nodes(0.5)">kL = 0.5/π</button>
|
||||
<button onclick="Nodes(1.5)">kL = 1.5/π</button>
|
||||
<button onclick="Nodes(2.5)">kL = 2.5/π</button>
|
||||
<button onclick="Nodes(3.5)">kL = 3.5/π</button>
|
||||
<button onclick="Nodes(4.5)">kL = 4.5/π</button>
|
||||
<button onclick="Nodes(5.5)">kL = 5.5/π</button>
|
||||
<button onclick="Nodes(6.5)">kL = 6.5/π</button>
|
||||
<button onclick="Nodes(7.5)">kL = 7.5/π</button>
|
||||
<button onclick="Nodes(8.5)">kL = 8.5/π</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var c = document.getElementById("myCanvas");
|
||||
var ctx = c.getContext("2d");
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
var nodes = .5;
|
||||
var nn = 42
|
||||
var eps = 20 / (nodes + 1);
|
||||
var kl = Math.PI * nodes;
|
||||
var o = 2 * nodes;
|
||||
var xPos = -90;
|
||||
var yPos = -50;
|
||||
var m = 1;
|
||||
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2)
|
||||
ctx.scale(6, -6);
|
||||
|
||||
function Clear(ctx)
|
||||
{
|
||||
ctx.clearRect(-c.width, -c.height, c.width * 2, c.height * 2);
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
Clear(ctx);
|
||||
Draw();
|
||||
m += 1;
|
||||
console.log(m);
|
||||
setTimeout(Update, 1000/60)
|
||||
}
|
||||
|
||||
function Draw()
|
||||
{
|
||||
drawOscillatingSpring(1, 7, 160, 10, 50, xPos, 0, 0.1)
|
||||
}
|
||||
|
||||
function drawOscillatingSpring(a, b, xSize, ySize, numLoops, x, y, tStep)
|
||||
{
|
||||
//Draws coiled spring using prolate cycloid
|
||||
var tStart = Math.PI / 2;
|
||||
var tEnd = (3 * Math.PI / 2) + (2 * Math.PI * numLoops);
|
||||
var xEnd = a * tEnd - b * Math.sin(tEnd);
|
||||
var yEnd = a + b;
|
||||
var xFactor = xSize / xEnd;
|
||||
var yFactor = ySize / yEnd;
|
||||
var xShiftA = - a * (Math.PI / 2) + b * Math.sin(Math.PI / 2);
|
||||
var yShift = y - a + b * Math.cos(Math.PI / 2);
|
||||
ctx.beginPath();
|
||||
var xDisplacement = eps * Math.sin(m * 0.1) * Math.sin((xFactor * (a * Math.PI / 2 - b * Math.sin(Math.PI / 2)) + xShiftA) * nodes * Math.PI / xSize);
|
||||
ctx.moveTo(xShiftA + x + xDisplacement + xFactor * (a * Math.PI / 2 - b * Math.sin(Math.PI / 2)), yShift + yFactor * (a - b * Math.cos(Math.PI / 2)));
|
||||
for (t = tStart; t <= tEnd; t += tStep)
|
||||
{
|
||||
xDisplacement = eps * Math.sin(m * 0.1) * Math.sin((xFactor * (a * t - b * Math.sin(t)) + xShiftA) * nodes * Math.PI / xSize);
|
||||
//ctx.moveTo(xShiftA + x + xDisplacement + xFactor * (a * t - b * Math.sin(t)), yShift + yFactor * (a - b * Math.cos(t)));
|
||||
ctx.lineTo(xShiftA + x + xDisplacement + xFactor * (a * (t + tStep) - b * Math.sin(t + tStep)), yShift + yFactor * (a - b * Math.cos(t + tStep)));
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function Nodes(num)
|
||||
{
|
||||
nodes = num;
|
||||
btn.textContent = "kL = " + num;
|
||||
eps = 20 / (nodes + 1);
|
||||
kl = Math.PI * nodes;
|
||||
o = 2 * nodes;
|
||||
}
|
||||
|
||||
document.onkeypress = function (e) {
|
||||
e = e || window.event;
|
||||
if (e.keyCode == 49)
|
||||
{
|
||||
nodes = .5;
|
||||
} else if (e.keyCode == 50)
|
||||
{
|
||||
nodes = 1.5;
|
||||
} else if (e.keyCode == 51)
|
||||
{
|
||||
nodes = 2.5;
|
||||
} else if (e.keyCode == 52)
|
||||
{
|
||||
nodes = 3.5;
|
||||
} else if (e.keyCode == 53)
|
||||
{
|
||||
nodes = 4.5;
|
||||
} else if (e.keyCode == 54)
|
||||
{
|
||||
nodes = 5.5;
|
||||
} else if (e.keyCode == 55)
|
||||
{
|
||||
nodes = 6.5;
|
||||
} else if (e.keyCode == 56)
|
||||
{
|
||||
nodes = 7.5;
|
||||
} else if (e.keyCode == 57)
|
||||
{
|
||||
nodes = 8.5;
|
||||
}
|
||||
btn.textContent = "kl = " + nodes;
|
||||
eps = 20 / (nodes + 1);
|
||||
kl = Math.PI * nodes;
|
||||
o = 2 * nodes;
|
||||
};
|
||||
|
||||
window.addEventListener('resize', function(event) {
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
ctx.translate(c.width / 2, c.height / 2);
|
||||
ctx.scale(6, -6);
|
||||
}, true);
|
||||
|
||||
Update();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
<p xmlns:cc="http://creativecommons.org/ns#" style="font-size: 1vw; bottom: 0px; position: absolute;">
|
||||
This work is licensed under
|
||||
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY-NC-ND 4.0<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/nd.svg?ref=chooser-v1"></a></p>
|
||||
</html>
|
||||
Reference in New Issue
Block a user