site-bkgs

My website backgrounds.
Log | Files | Refs | LICENSE

commit 88590b291d4cb0e3534f4e2c50a4e00bc818ae98
parent 78798652b23d537bfdb3c675e96a9ab8e6856797
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date:   Tue, 20 Apr 2021 02:26:43 -0700

Clear the page, microoptimizations, comments.

Diffstat:
Mconway.js | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/conway.js b/conway.js @@ -71,10 +71,15 @@ function startAnimating(fps) { animate(); } +// Optimized drawing function. function draw() { - let drawCell = { 'x' : 0, 'y' : 0, 'width' : (window.innerWidth / rows), 'height' : (window.innerHeight / cols)}; - + let wWidth = window.innerWidth; + let wHeight = window.innerHeight; + let drawCell = { 'x' : 0, 'y' : 0, 'width' : wWidth / rows, 'height' : wHeight / cols}; + tmpContext.clearRect(0, 0, tmpCanvas.width, tmpCanvas.height); + context.clearRect(0, 0, canvas.width, canvas.height); + tmpContext.beginPath(); tmpContext.fillStyle = '#FFFFFF'; for(let i = 0; i < rows; i++) { @@ -89,7 +94,7 @@ function draw() { tmpContext.fill(); tmpContext.closePath(); - context.drawImage(tmpCanvas, 0, 0, window.innerWidth, window.innerHeight); + context.drawImage(tmpCanvas, 0, 0, wWidth, wHeight); } function animate() {