From 0dd497342b006b1a48ca87571450f86fd1c56151 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Wed, 12 Feb 2020 21:56:12 +0100 Subject: [PATCH] Shapes appear in the window view all the time now --- voicegardens/static/voicegardens.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/voicegardens/static/voicegardens.js b/voicegardens/static/voicegardens.js index 8c369ba..5625f76 100644 --- a/voicegardens/static/voicegardens.js +++ b/voicegardens/static/voicegardens.js @@ -216,12 +216,6 @@ class GeneratedShape { this.accelX = 0.0; this.accelY = 0.0; - // The x, y destination values which the shape moves towards. This can be - // calculated against the `mouseX` and `mouseY` values, for example. Then - // the shape will follow the mouse. - this.deltaX = 0.0; - this.deltaY = 0.0; - // The speed at which the shape 'springs' towards its final destination. this.springing = 0.0009; @@ -275,13 +269,19 @@ class GeneratedShape { this.angle = radians(360 / this.edges); // ??? - this.centerX = random(windowWidth); - this.centerY = random(windowHeight); + this.centerX = random(windowWidth) - toScreenX; + this.centerY = random(windowHeight) - toScreenY; // new destination for the shapes this.destX = random(windowWidth); this.destY = random(windowHeight); + // The x, y destination values which the shape moves towards. This can be + // calculated against the `mouseX` and `mouseY` values, for example. Then + // the shape will follow the mouse. + this.deltaX = this.destX - this.centerX - toScreenX; + this.deltaY = this.destY - this.centerY - toScreenY; + this.initialise(); }