Skip to content

Instantly share code, notes, and snippets.

@Somrlik
Created April 1, 2020 23:12
Show Gist options
  • Save Somrlik/d2e4bbec5077664abe20aeef024cc096 to your computer and use it in GitHub Desktop.
Save Somrlik/d2e4bbec5077664abe20aeef024cc096 to your computer and use it in GitHub Desktop.
((m, a, n, d, e, l, b, r, o, t, _?: any) => {
_ = m.createElement(n), t.style.margin = r, t.append(_), _.style.width = e, _.style.height = d, t.style.overflow = o;
const ctx = _.getContext(l);
const p = (pos: [number, number]): number => {
let rcr = pos[0], icr = pos[1];
for(var i = 0; i < b; i++) {
const trc = (rcr * rcr - icr * icr + pos[0]), tic = (2 * rcr * icr + pos[1]);
rcr = trc, icr = tic;
if(rcr * icr > 5) return (i / b * 100);
}
return 0;
}
const q = () => {
_.width = _.clientWidth, _.height = _.clientHeight;
const z = (48.61 / (Math.log(_.width) + 5.67 ) + 210 ), spx = ((_.width / 2) * 1.15), spy = ((_.height / 2) * 0.90);
for(let x = 0; x < _.width; x++)
for(let y = 0; y < _.height; y++) {
const m = p([(x - spx) / z, (y - spy) / z]);
ctx.fillStyle = m === 0 ? '#000' : `hsl(0, 100%, ${m}%)`;
ctx.fillRect(x, y, 1,1);
}
}
q();
window.addEventListener('resize', q);
})(document, 'body', 'canvas', '100vh', '100vw', '2d', 125, '0', 'hidden', document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment