From 18639412c260c2af1d4268cb3a3209e208276005 Mon Sep 17 00:00:00 2001 From: triethyl Date: Sun, 15 Feb 2026 23:37:22 -0500 Subject: changed background --- site/themes/sine/static/js/oldish-background.js | 90 +++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 site/themes/sine/static/js/oldish-background.js (limited to 'site/themes/sine/static/js/oldish-background.js') diff --git a/site/themes/sine/static/js/oldish-background.js b/site/themes/sine/static/js/oldish-background.js new file mode 100644 index 0000000..3a55a0f --- /dev/null +++ b/site/themes/sine/static/js/oldish-background.js @@ -0,0 +1,90 @@ +document.addEventListener("DOMContentLoaded", () => { + const canvas = document.getElementById("background"); + + if (canvas.getContext) { + const ctx = canvas.getContext("2d"); + + // Source - https://stackoverflow.com/a/58673385 + // Posted by Sanxofon, modified by community. See post 'Timeline' for change history + // Retrieved 2026-02-15, License - CC BY-SA 4.0 + + var w = canvas.width; // Canvas width => Frequency is relative to this + var h = canvas.height/2; // Canvas height over two => Amplitude: Volume + var f=1; // How many cycles per canvas width => Frequency: Tone & Speed + // Calculates y position from x + function calcSineY(x) { + // This is the meat (unles you are vegan) + // Note that: + // h is the amplitude of the wave + // x is the current x value we get every time interval + // 2 * PI is the length of one cycle (full circumference) + // f/w is the frequency fraction + return h - h * Math.sin( x * 2 * Math.PI * (f/w) ); + } + function drawSine(x){ + ctx.clearRect(0, 0, w, h*2); + //draw x axis + ctx.beginPath(); // Draw a new path + ctx.strokeStyle = "green"; // Pick a color + ctx.moveTo(0,h); // Where to start drawing + ctx.lineTo(w,h); // Where to draw to + ctx.stroke(); // Draw + + // // draw horizontal line of current amplitude + // ctx.beginPath(); // Draw a new path + // ctx.moveTo(0,h); // Where to start drawing + // ctx.strokeStyle = "gray"; // Pick a color + // for(var i=0;iw){ + // x=0; // x cannot be more than canvas with, so back to 0 + // f++; // increment frequency for demonstration + // } + },10); // Loop every 10 milliseconds + + } else { + + } +}); -- cgit v1.2.3