159 lines
4.2 KiB
HTML
159 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- ahhh -->
|
|
|
|
<body style="margin:0;overflow: hidden;">
|
|
<canvas id="myCanvas" width="10" height="10" style="display: block;box-sizing: border-box;">
|
|
Your browser does not support the HTML5 canvas tag.</canvas>
|
|
<script>
|
|
let c = document.getElementById("myCanvas");
|
|
let ctx = c.getContext("2d");
|
|
ctx.canvas.width = window.innerWidth;
|
|
ctx.canvas.height = window.innerHeight;
|
|
|
|
|
|
|
|
let deg_per_sec = 30 / 200000;
|
|
let xx_per_sec = 10;
|
|
let time = 99999999;
|
|
let fps = 60;
|
|
|
|
centerX = ctx.canvas.width / 2;
|
|
centerY = ctx.canvas.height / 2;
|
|
|
|
let xx = 0
|
|
rotation = 0; //was = j = angle
|
|
currentFrame = 0; //was = i
|
|
|
|
|
|
|
|
function render() {
|
|
if (currentFrame < time / (1 / fps)) {
|
|
setTimeout(() => {
|
|
render();
|
|
render_clear();
|
|
|
|
// Draw_Phyllotaxis(rotation + 3.1);
|
|
// Draw_Phyllotaxis(rotation + 1.5);
|
|
Draw_Spiral(rotation +1);
|
|
// Draw_Phyllotaxis(rotation/5000);
|
|
|
|
// Draw_center(); //Debugging
|
|
// DrawBorder();
|
|
}, 1000 / fps);
|
|
rotation += deg_per_sec / fps; // was = j = angle, now = rotation
|
|
xx += xx_per_sec / fps; // was = j = angle, now = rotation
|
|
currentFrame += 1; // was = i
|
|
}
|
|
}
|
|
|
|
render();
|
|
|
|
function Draw_Spiral(angle) {
|
|
// colour1 = [255, 170, 0];
|
|
// colour2 = [255, 0, 221];
|
|
colour1 = [45, 129, 252];
|
|
colour2 = [252, 3, 98];
|
|
|
|
var c = 1; //something to do with width. but not width
|
|
|
|
for (let n = 0; n < 1000; n += 1) {
|
|
ncolour = LerpRGB(colour1, colour2, Math.cos(rad(n / 2)));
|
|
var a = n * angle + (Math.sin((angle *n*3)))
|
|
// var r = c * Math.sqrt(n);
|
|
var r = c * n;
|
|
var x = r * Math.cos(a) + centerX;
|
|
var y = r * Math.sin(a) + centerY;
|
|
|
|
ctx.beginPath();
|
|
ctx.arc(x, y, 8, 0, 2 * Math.PI);
|
|
ctx.fillStyle = colourToText(ncolour);
|
|
ctx.fill();
|
|
|
|
}
|
|
// for (let n = 0; n < 300; n += 1) {
|
|
// ncolour = LerpRGB(colour1, colour2, Math.cos(rad(n / 2)));
|
|
// var a = n * (angle)//137.5;
|
|
// // var r = c * Math.sqrt(n);
|
|
// var r = c * n;
|
|
// var x = r * Math.cos(a) + centerX;
|
|
// var y = r * Math.sin(a) + centerY;
|
|
|
|
// ctx.beginPath();
|
|
// ctx.arc(x, y, 8, 0, 2 * Math.PI);
|
|
// ctx.fillStyle = colourToText(ncolour);
|
|
// ctx.fill();
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
function Draw_SpiralAccident(angle) {
|
|
// colour1 = [255, 170, 0];
|
|
// colour2 = [255, 0, 221];
|
|
colour1 = [45, 129, 252];
|
|
colour2 = [252, 3, 98];
|
|
|
|
var c = 2; //something to do with width. but not width
|
|
|
|
for (let n = 0; n < 300; n += 1) {
|
|
ncolour = LerpRGB(colour1, colour2, Math.cos(rad(n / 2)));
|
|
var a = n * angle + (Math.sin((n * angle) * 3))
|
|
// var r = c * Math.sqrt(n);
|
|
var r = c * n;
|
|
var x = r * Math.cos(a) + centerX;
|
|
var y = r * Math.sin(a) + centerY;
|
|
|
|
ctx.beginPath();
|
|
ctx.arc(x, y, 8, 0, 2 * Math.PI);
|
|
ctx.fillStyle = colourToText(ncolour);
|
|
ctx.fill();
|
|
|
|
}
|
|
// for (let n = 0; n < 300; n += 1) {
|
|
// ncolour = LerpRGB(colour1, colour2, Math.cos(rad(n / 2)));
|
|
// var a = n * (angle)//137.5;
|
|
// // var r = c * Math.sqrt(n);
|
|
// var r = c * n;
|
|
// var x = r * Math.cos(a) + centerX;
|
|
// var y = r * Math.sin(a) + centerY;
|
|
|
|
// ctx.beginPath();
|
|
// ctx.arc(x, y, 8, 0, 2 * Math.PI);
|
|
// ctx.fillStyle = colourToText(ncolour);
|
|
// ctx.fill();
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
function rad(degrees) {
|
|
var pi = Math.PI;
|
|
return degrees * (pi / 180);
|
|
}
|
|
|
|
function LerpRGB(a, b, t) {
|
|
if (t < 0) {
|
|
t *= -1;
|
|
}
|
|
var newColor = [0, 0, 0];
|
|
newColor[0] = a[0] + (b[0] - a[0]) * t;
|
|
newColor[1] = a[1] + (b[1] - a[1]) * t;
|
|
newColor[2] = a[2] + (b[2] - a[2]) * t;
|
|
return newColor;
|
|
}
|
|
|
|
function colourToText(colour) {
|
|
return "rgb(" + colour[0] + "," + colour[1] + "," + colour[2] + ")"
|
|
}
|
|
|
|
function render_clear() {
|
|
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
ctx.fillStyle = "black";
|
|
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |