Browse Source

Towards more random shapes

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

Loading…
Cancel
Save