Use parentNode's width and height instead of window's sizes.
FedericoBiccheddu opened this issue · comments
With a simple change the canvas can be limited to the container, even the body, when it's used as a background, e.g. in a header element.
canvas.width = canvas.parentNode.offsetWidth;
canvas.height = canvas.parentNode.offsetHeight;
If it's ok for you, I can try to submit a PR.
A PR would be nice 👍