From a3a873e54e6ac6c7dc3b6e2e08d06ae4257f14e3 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Thu, 12 Jul 2018 01:11:57 +0200 Subject: [PATCH] Changed the size of the canvas to be responsive to screen width to some extent and added a translate for wide screens so the canvas is pulled closer up. --- public/sketch.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public/sketch.js b/public/sketch.js index 6b0d938..2cd10c7 100644 --- a/public/sketch.js +++ b/public/sketch.js @@ -2,20 +2,29 @@ let angle = 0; let w = 40; let ma; let maxD; +let window_w; function setup() { - createCanvas(600, 600, WEBGL); - ma = atan(1 / sqrt(2)) + window_w = min(window.innerWidth, 1200); + createCanvas(window_w, window_w, WEBGL); + ma = atan(1 / sqrt(2)); maxD = dist(0, 0, 200, 200); } function draw() { background("#1e1e1e"); - ortho(-700, 700, 700, -700, 0, 1200); + + let o_w = window_w + 100; + ortho(-o_w, o_w, o_w, -o_w, 0, o_w + 500); + + if (o_w > 750) { + translate(0, o_w * 0.35); + } rotateX(-ma); rotateY(QUARTER_PI); + rectMode(CENTER); let offset = 0;