diff --git a/docs/art/brownian_motion/main.js b/docs/art/brownian_motion/main.js index 63580c6..6d884f9 100644 --- a/docs/art/brownian_motion/main.js +++ b/docs/art/brownian_motion/main.js @@ -3,34 +3,25 @@ // Date: 22.09.2022 // Global variables -const width = 600; -const height = 600; - -const xmid = width / 2; -const ymid = height / 2; - -const n_particles = 100; - let p = []; function setup() { - let canvas = createCanvas(width, height); + let canvas = createCanvas(windowWidth, windowHeight); canvas.parent("canvas"); - + let n_particles = int(windowHeight * windowHeight * 0.001); for (let i = 0; i < n_particles; i++) { - let x = random(width); - let y = random(height); - let dx = random(-5, 5); - let dy = random(-5, 5); + let x = random(windowWidth); + let y = random(windowHeight); + let dx = random(-10, 10); + let dy = random(-10, 10); let size = random(1, 5); p.push(new Point(x, y, dx, dy, size)); } - } function draw() { clear(); - for (let i=0; i < n_particles; i++) { + for (let i=0; i < p.length; i++) { p[i].move(); p[i].draw(); } diff --git a/docs/art/fibonacci_sphere/main.js b/docs/art/fibonacci_sphere/main.js index fcac034..f8f031d 100644 --- a/docs/art/fibonacci_sphere/main.js +++ b/docs/art/fibonacci_sphere/main.js @@ -3,11 +3,7 @@ // Based on Game of Life by Joan Soler-Adillon. // Global variables -const width = 600; -const height = width; - -const xmid = width / 2; -const ymid = height / 2; +let width, height, xmid, ymid, multiplier; const size = 3; const PI = Math.PI; @@ -15,10 +11,15 @@ const GA = (3 - Math.sqrt(5)) * PI; let N = 100; let factor = 1; -let multiplier = width / 2 - 10; function setup() { - let canvas = createCanvas(width, height); + width = Math.min(windowWidth, windowHeight); + height = width; + xmid = windowWidth/2; + ymid = windowHeight/2; + multiplier = width / 2 - 10; + + let canvas = createCanvas(windowWidth, windowHeight); canvas.parent("canvas"); }