Browse Source

Towards more random shapes

main
Luke Murphy 5 years ago
parent
commit
1eb743edcd
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 18
      voicegardens/static/voicegardens.js

18
voicegardens/static/voicegardens.js

@ -139,23 +139,31 @@ class GeneratedShape {
this.accelX = 0.0;
this.accelY = 0.0;
this.deltaX = 0.0;
this.deltaY = 0.0;
this.springing = 0.0009;
this.damping = 0.98;
this.organicConstant = 1.0;
this.organicConstant = random(-5, 5);
this.startXs = [];
this.startYs = [];
this.xs = [];
this.ys = [];
this.angle = [];
this.frequency = [];
this.edges = 5;
this.radius = random(10, 180);
this.rotAngle = random(10, 140);
this.randomX = random(-77, 77);
this.randomY = random(-77, 77);
this.initialise();
}
@ -228,8 +236,10 @@ class GeneratedShape {
fill(this.colour);
for (let i = 0; i < this.edges; i++) {
this.startXs[i] = centerX + cos(radians(this.rotAngle)) * this.radius;
this.startYs[i] = centerY + sin(radians(this.rotAngle)) * this.radius;
this.startXs[i] =
centerX + cos(radians(this.rotAngle) * i) * this.radius + this.randomX;
this.startYs[i] =
centerY + sin(radians(this.rotAngle) * i) * this.radius + this.randomY;
this.rotAngle += 360 / this.edges;
}
@ -245,12 +255,12 @@ class GeneratedShape {
/**
* Move the shape vectors.
**/
this.deltaX = mouseX - centerX;
this.deltaY = mouseY - centerY;
this.deltaX *= this.springing;
this.deltaY *= this.springing;
this.accelX += this.deltaX;
this.accelY += this.deltaY;

Loading…
Cancel
Save