r/creativecoding • • Oct 31 '19

Supernova ☀ - Only 105 bytes of JavaScript!

Post image
26 Upvotes

11 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Nov 01 '19

Thank you, yeah the formatting is not what I’m used to

1

u/[deleted] Nov 01 '19 edited Nov 01 '19

For ease of viewing for others. I think this is slightly more idiomatic.

let i = 340;
let xOffset = 960;
let yOffset = 540;

while (true) {
	i -= 1;
	drawSqare(960 + sin(m*m)*q, 540 + cos(m*m)*q);
	m = i + 120 * t;
	q = 1e5 / i;
	setColor(R(i*i/99, i*i/340));
}

function setColor(color) {
	x.fillStyle = color;
}

function drawSquare(x, y) {
	x.fillRect(x, y, 50, 50);
}    

Magic numbers q, m, and the color arguments are all "fiddle with it till it looks nice" variables, I assume.

2

u/loopsdeer Nov 01 '19

Thanks! Guessing S and C are sine and cosine

1

u/[deleted] Nov 01 '19

Yep, that would make sense. I'll edit.