commit 8bdd45244a13e6521ce2997d2f7e69382afcc48b
parent f5cab4630283deacf8baddee974399581fe254e7
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date: Tue, 20 Apr 2021 19:45:50 -0700
main file, lowered rows and cols.
Diffstat:
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/conway.js b/conway.js
@@ -8,8 +8,8 @@ let canvas;
let context;
// Rows and columns of the board.
-let rows = 100;
-let cols = 50;
+let rows = 150;
+let cols = 75;
// Divisor for likelyhood the cell starts out as alive.
// For example: 4 means 1/4 chance.
@@ -39,9 +39,10 @@ let tmpContext;
function init() {
let newCanvas = document.createElement('canvas');
newCanvas.setAttribute("id", 'bkg-canvas');
- newCanvas.style['position'] = 'absolute';
+ newCanvas.style['position'] = 'fixed';
newCanvas.style['left'] = 0;
newCanvas.style['right'] = 0;
+ newCanvas.style['top'] = 0;
newCanvas.style['z-index'] = -1;
newCanvas.width = window.innerWidth;
newCanvas.height = window.innerHeight;
@@ -172,7 +173,7 @@ function animate() {
draw();
- // TESTING...Report #seconds since start and achieved fps.
+
let sinceStart = now - startTime;
let currentFps = Math.round(1000 / (sinceStart / ++frameCount) * 100) / 100;
context.fillStyle = 'white';
@@ -187,3 +188,11 @@ function animate() {
init();
startAnimating(20);
+
+window.addEventListener('resize', _ => {
+ tmpCanvas.width = window.innerWidth;
+ tmpCanvas.height = window.innerHeight;
+
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+});
diff --git a/main.js b/main.js
@@ -0,0 +1,19 @@
+"use strict";
+// This file loads a random background.
+
+// List of script paths.
+let bkgScripts = ['conway.js'];
+let urlPrefix = 'https://www.ryanmj.xyz/scripts/site-bkgs/';
+// A randomly selected script.
+let randomScript = bkgScripts[Math.floor(Math.random() * bkgScripts.length)];
+
+
+// Adding the script tag to the head as suggested before
+let head = document.head;
+let script = document.createElement('script');
+
+script.type = 'text/javascript';
+script.src = urlPrefix + randomScript;
+
+// Fire the loading
+head.appendChild(script);