Added the rest of the files
This commit is contained in:
222
11-2.html
Normal file
222
11-2.html
Normal file
@@ -0,0 +1,222 @@
|
||||
<!--
|
||||
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 11-2
|
||||
</title>
|
||||
<style>
|
||||
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>
|
||||
|
||||
<script>
|
||||
var c = document.getElementById("myCanvas");
|
||||
var ctx = c.getContext("2d");
|
||||
ctx.canvas.width = window.innerWidth;
|
||||
ctx.canvas.height = window.innerHeight;
|
||||
|
||||
var l1 = 20;
|
||||
var n1 = 3;
|
||||
var n2 = 2;
|
||||
var l2 = l1 * n1/n2;
|
||||
var theta1 = .5;
|
||||
var theta2 = Math.atan(n1 * Math.sin(theta1) / n2 / Math.sqrt(1 - (Math.pow(n1 * Math.sin(theta1) / n2 , 2))));
|
||||
var clv = "#ff0000";
|
||||
var cll = "#00ff00";
|
||||
var clb = "#0000ff";
|
||||
var xPos = 0;
|
||||
var yPos = -35;
|
||||
var xPosA = 10;
|
||||
var yPosA = -35;
|
||||
var xPosB = -15;
|
||||
var yPosB = -15;
|
||||
|
||||
var height = 75;
|
||||
var ttheta1 = Math.tan(theta1);
|
||||
var ttheta2 = Math.tan(theta2);
|
||||
var d1 = height * ttheta1;
|
||||
var d2 = height * ttheta2;
|
||||
|
||||
var l1c = l1 / Math.cos(theta1);
|
||||
var l2c = l2 / Math.cos(theta2);
|
||||
var vc = l1 / Math.sin(theta1);
|
||||
|
||||
var kx1 = 10 * Math.cos(theta1) * n1;
|
||||
var ky1 = 10 * Math.sin(theta1) * n1;
|
||||
var kx11 = kx1 - 3 * Math.cos(theta1 - Math.PI / 6);
|
||||
var ky11 = ky1 - 3 * Math.sin(theta1 - Math.PI / 6);
|
||||
var kx12 = kx1 - 3 * Math.cos(theta1 + Math.PI / 6);
|
||||
var ky12 = ky1 - 3 * Math.sin(theta1 + Math.PI / 6);
|
||||
var kx2 = 10 * Math.cos(theta2) * n2;
|
||||
var ky2 = 10 * Math.sin(theta2) * n2;
|
||||
var kx21 = kx2 - 3 * Math.cos(theta2 - Math.PI / 6);
|
||||
var ky21 = ky2 - 3 * Math.sin(theta2 - Math.PI / 6);
|
||||
var kx22 = kx2 - 3 * Math.cos(theta2 + Math.PI / 6);
|
||||
var ky22 = ky2 - 3 * Math.sin(theta2 + Math.PI / 6);
|
||||
var mmax = 30;
|
||||
var m = 1;
|
||||
var x1 = l1c * (mmax - m) / mmax;
|
||||
var x = x1;
|
||||
var xx = 0;
|
||||
|
||||
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2);
|
||||
ctx.scale(3, -3);
|
||||
|
||||
function Clear(ctx)
|
||||
{
|
||||
ctx.clearRect(-c.width, -c.height, c.width * 2, c.height * 2);
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
x1 = l1c * (mmax - m) / mmax;
|
||||
Draw();
|
||||
m += 1;
|
||||
if (m > mmax)
|
||||
{
|
||||
m = 1;
|
||||
}
|
||||
setTimeout(Update, 1000/60)
|
||||
}
|
||||
|
||||
function Draw()
|
||||
{
|
||||
Clear(ctx);
|
||||
ctx.strokeStyle = clb;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos, yPos + height);
|
||||
ctx.lineTo(xPos, yPos);
|
||||
ctx.stroke();
|
||||
x = x1;
|
||||
thex1loopllp1();
|
||||
}
|
||||
|
||||
function thex1loopllp1()
|
||||
{
|
||||
if (x > 50)
|
||||
{
|
||||
outx1loopllp1();
|
||||
return;
|
||||
}
|
||||
ctx.strokeStyle = cll
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos - x, yPos);
|
||||
ctx.lineTo(xPos - x - d1, yPos + height);
|
||||
ctx.stroke();
|
||||
x += l1c;
|
||||
thex1loopllp1();
|
||||
}
|
||||
|
||||
function outx1loopllp1()
|
||||
{
|
||||
x -= l1c;
|
||||
y = vc - x1 / ttheta1;
|
||||
they1loopllp1();
|
||||
}
|
||||
|
||||
function they1loopllp1()
|
||||
{
|
||||
if (y > height)
|
||||
{
|
||||
outy1loopllp1();
|
||||
return;
|
||||
}
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos, yPos + y);
|
||||
ctx.lineTo(xPos - d1, yPos + y + height);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos, yPos + y);
|
||||
ctx.lineTo(xPos + d2, yPos + y - height);
|
||||
ctx.stroke();
|
||||
y += vc;
|
||||
they1loopllp1();
|
||||
}
|
||||
|
||||
function outy1loopllp1()
|
||||
{
|
||||
y -= vc;
|
||||
xx = l2c - (height - y) * ttheta2;
|
||||
thex2loopllp1();
|
||||
}
|
||||
|
||||
function thex2loopllp1()
|
||||
{
|
||||
if (xx > 50)
|
||||
{
|
||||
outx2loopllp1();
|
||||
return;
|
||||
}
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xx + xPos, yPos + height);
|
||||
ctx.lineTo(xPos + xx + d2, yPos);
|
||||
ctx.stroke();
|
||||
xx += l2c;
|
||||
thex2loopllp1();
|
||||
}
|
||||
|
||||
function outx2loopllp1()
|
||||
{
|
||||
ctx.strokeStyle = clv;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosA - 40, yPosA + 20);
|
||||
ctx.lineTo(xPosA - 40 + kx1, yPosA + 20 + ky1);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosB + 20, yPosB + 20);
|
||||
ctx.lineTo(xPosB + 20 + kx2, yPosB + 20 + ky2);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosA + kx1 - 40, yPosA + ky1 + 20);
|
||||
ctx.lineTo(xPosA - 40 + kx11, yPosA + 20 + ky11);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosA + kx1 - 40, yPosA + ky1 + 20);
|
||||
ctx.lineTo(xPosA - 40 + kx12, yPosA + 20 + ky12);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosB + kx2 + 20, yPosB + ky2 + 20);
|
||||
ctx.lineTo(xPosB + 20 + kx21, yPosB + 20 + ky21);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPosB + kx2 + 20, yPosB + ky2 + 20);
|
||||
ctx.lineTo(xPosB + 20 + kx22, yPosB + 20 + ky22);
|
||||
ctx.stroke();
|
||||
ctx.clearRect(-c.width, -c.height, c.width * 2, (c.height + yPos));
|
||||
ctx.clearRect(-c.width, yPos + height, c.width * 2, c.height * 2);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', function(event) {
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
ctx.translate(c.width / 2, c.height / 2);
|
||||
ctx.scale(3, -3);
|
||||
}, 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