Added the rest of the files
This commit is contained in:
162
10-1.html
Normal file
162
10-1.html
Normal file
@@ -0,0 +1,162 @@
|
||||
<!--
|
||||
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 10-1
|
||||
</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");
|
||||
c.width = window.innerWidth;
|
||||
c.height = window.innerHeight;
|
||||
var h = 20;
|
||||
var dt = .08;
|
||||
var t = -1;
|
||||
var m = 1;
|
||||
var mmax = 100;
|
||||
var xPos = -50;
|
||||
var yPos = -50;
|
||||
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2)
|
||||
ctx.scale(3, -3);
|
||||
|
||||
function fnf(t)
|
||||
{
|
||||
var fd = 0;
|
||||
if (t >= 0)
|
||||
{
|
||||
fd = 1 - t;
|
||||
}
|
||||
if (t < 0)
|
||||
{
|
||||
fd = 1 + t;
|
||||
}
|
||||
if (t > 1)
|
||||
{
|
||||
fd = 0;
|
||||
}
|
||||
if (t < -1)
|
||||
{
|
||||
fd = 0;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
function Clear(ctx)
|
||||
{
|
||||
ctx.clearRect(-c.width, -c.height, c.width * 2, c.height * 2);
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
Clear(ctx);
|
||||
Draw();
|
||||
m += 1;
|
||||
if (m > mmax)
|
||||
{
|
||||
m = 1;
|
||||
t = -1;
|
||||
}
|
||||
console.log(m);
|
||||
setTimeout(Update, 1000/60)
|
||||
}
|
||||
|
||||
function Draw()
|
||||
{
|
||||
xc = 5 + 15 * t;
|
||||
xc1 = 5 + 15 * (t - 1);
|
||||
xc2 = 5 + 15 * (t + 1);
|
||||
if (t < 0)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40 + h * fnf(-t));
|
||||
ctx.lineTo(xPos + xc2, yPos + 40);
|
||||
ctx.lineTo(xPos + 95, yPos + 40);
|
||||
ctx.stroke();
|
||||
}
|
||||
if (t >= 0 && t < 1)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40 + h * fnf(-t));
|
||||
ctx.lineTo(xPos + xc, yPos + 40 + h);
|
||||
ctx.lineTo(xPos + xc2, yPos + 40);
|
||||
ctx.lineTo(xPos + 95, yPos + 40);
|
||||
ctx.stroke();
|
||||
}
|
||||
if (t >= 1 && t < 5)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40);
|
||||
ctx.lineTo(xPos + xc1, yPos + 40);
|
||||
ctx.lineTo(xPos + xc, yPos + 40 + h);
|
||||
ctx.lineTo(xPos + xc2, yPos + 40);
|
||||
ctx.lineTo(xPos + 95, yPos + 40);
|
||||
ctx.stroke();
|
||||
}
|
||||
if (t >= 5 && t < 6)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40);
|
||||
ctx.lineTo(xPos + xc1, yPos + 40);
|
||||
ctx.lineTo(xPos + xc, yPos + 40 + h);
|
||||
ctx.lineTo(xPos + 95, yPos + 40 + h * fnf(6-t));
|
||||
ctx.stroke();
|
||||
}
|
||||
if (t >= 6 && t < 7)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40);
|
||||
ctx.lineTo(xPos + xc1, yPos + 40);
|
||||
ctx.lineTo(xPos + 95, yPos + 40 + h * fnf(6-t));
|
||||
ctx.stroke();
|
||||
}
|
||||
if (t >= 7 && t < 8)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xPos + 5, yPos + 40);
|
||||
ctx.lineTo(xPos + 95, yPos + 40);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.beginPath();
|
||||
ctx.arc(xPos + 5, yPos + 40 + h * fnf(-t), 1, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
t += dt;
|
||||
}
|
||||
|
||||
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