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(); }