141 lines
4.5 KiB
HTML
141 lines
4.5 KiB
HTML
<!--
|
|
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 6-2
|
|
</title>
|
|
<style>
|
|
#increase
|
|
{
|
|
width: 50;
|
|
height: 50;
|
|
top: 12.5;
|
|
left: 12.5;
|
|
position: absolute;
|
|
background-image: url(upArrow.png);
|
|
background-repeat: no-repeat;
|
|
background-size: cover;
|
|
}
|
|
|
|
#decrease
|
|
{
|
|
width: 50;
|
|
height: 50;
|
|
top: 75;
|
|
left: 12.5;
|
|
position: absolute;
|
|
background-image: url(downArrow.png);
|
|
background-repeat: no-repeat;
|
|
background-size: cover;
|
|
}
|
|
|
|
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>
|
|
<button id = "increase" onclick = "Increase()"></button>
|
|
<button id = "decrease" onclick = "Decrease()"></button>
|
|
|
|
<script>
|
|
var c = document.getElementById("myCanvas");
|
|
var ctx = c.getContext("2d");
|
|
c.width = window.innerWidth;
|
|
c.height = window.innerHeight;
|
|
k = .5;
|
|
a0 = 20;
|
|
a = a0 / k;
|
|
nn = 48;
|
|
mm0 = 12;
|
|
mm = mm0;
|
|
m = 1;
|
|
var xPos = -100;
|
|
var yPos = -75;
|
|
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()
|
|
{
|
|
Clear(ctx);
|
|
Draw();
|
|
m += 1;
|
|
ctx.strokeStyle = "#000000";
|
|
setTimeout(Update, 1000/60)
|
|
}
|
|
|
|
function Draw()
|
|
{
|
|
ctx.beginPath();
|
|
ctx.moveTo(xPos + 170, yPos + 20);
|
|
ctx.lineTo(xPos + 170, yPos + 140);
|
|
ctx.stroke();
|
|
ctx.beginPath();
|
|
ctx.arc(xPos + 170, yPos + 80 + a* Math.sin(k * Math.PI) * Math.sin(m / mm), 1, 0, Math.PI * 2);
|
|
ctx.stroke();
|
|
ctx.beginPath();
|
|
ctx.moveTo(xPos + 10, yPos + 80);
|
|
for (n = 0; n < nn; n++)
|
|
{
|
|
ctx.lineTo(xPos + 10 + 160 * (n + 1) / nn, yPos + 80 + a * Math.sin(k * (n+1) * Math.PI / nn) * Math.sin(m / mm));
|
|
}
|
|
ctx.stroke();
|
|
}
|
|
|
|
function Increase()
|
|
{
|
|
k += 1;
|
|
if (k >= 10)
|
|
{
|
|
k = 9.5;
|
|
}
|
|
mm = mm0 / k;
|
|
a = a0 / k;
|
|
}
|
|
|
|
function Decrease()
|
|
{
|
|
k -= 1;
|
|
if (k <= 0)
|
|
{
|
|
k = 0.5;
|
|
}
|
|
mm = mm0 / k;
|
|
a = a0 / k;
|
|
}
|
|
|
|
Update();
|
|
|
|
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);
|
|
|
|
</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> |