Repeatedly Refresh Webpage
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="2">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
</head>
<body>
<script>
document.body.innerHTML = Math.random() * 100;
</script>
</body>
</html>
Refresh a webpage every two seconds with:
<meta http-equiv="refresh" content="2">
Bat Signal
document.body.innerHTML = '<pre>'+`n2zh2
f8l2b2l8
b8pep8
7cpepc
5ijiji
3yyq
0
0
0
3yyq
5afy8fa
98f69a96f8
f4f2d6d2f4`.replace(/./g,c=>'* '[(n=parseInt(c,36))&1].repeat(n/2||49))
* *
**** * * ****
**** ******* ****
****** ******* ******
********* ********* *********
***********************************************
*************************************************
*************************************************
*************************************************
***********************************************
***** ********************* *****
**** *** ***** *** ****
** * *** * **
Fun js codegolf answer from user arnauld… Whole thread is very fun…
HSL to RGB JavaScript
const hsl2rgb = (h, s, l, o) => {
if (h > 1 || s > 1 || l > 1) {
h /= 360;
s /= 100;
l /= 100;
}
h *= 360;
let R, G, B, X, C;
h = (h % 360) / 60;
C = 2 * s * (l < .5 ? l : 1 - l);
X = C * (1 - Math.abs(h % 2 - 1));
R = G = B = l - C / 2;
h = ~~h;
R += [C, X, 0, 0, X, C][h];
G += [X, C, C, X, 0, 0][h];
B += [0, 0, X, C, C, X][h];
return `rgba(${~~(R * 255)}, ${~~(G * 255)}, ${~~(B * 255)}, ${o})`;
};
console.log(hsl2rgb(122, 50, 50, .5));
Taken from the Raphaël source… Always fun to browse – I’ve learned lots of great stuff from it 😀
Polar Forking Tweak
const FOUR_PI = 6 * Math.PI;
const { cos, sin } = Math;
const canvas = document.body.appendChild(
document.createElement('canvas')
);
const c = canvas.getContext('2d');
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
let inc = 0;
function draw() {
c.fillStyle = 'rgba(0, 0, 0, .3)'
c.fillRect(0, 0, canvas.width, canvas.height)
c.fillStyle = 'white';
const halfWidth = window.innerWidth / 2;
const halfHeight = window.innerHeight / 2;
let theta = 0,
a = 20 * Math.min(window.innerWidth, window.innerHeight) * 0.005,
x,
y;
c.save();
c.translate(halfWidth, halfHeight)
let b = 5 * cos(inc);
inc += .02;
for (let i = 0; theta < FOUR_PI; i++) {
let rad = a * (b + 10 * sin(theta / 3));
// randomly speed-coded and tweaked... leaving as is :D
x = rad * cos(theta + b / 10) * cos(b / 10 +theta * 2) * cos(theta * 2);
y = rad * sin(theta * 2) * cos(theta + b / 3) * cos(theta * 2);
c.fillRect(x,y, 2, 2);
theta += 0.04;
}
c.restore();
requestAnimationFrame(draw)
}
resize();
addEventListener('resize', resize);
draw();
Just randomly futzing with sin/cos…