Skip to content

Commit

Permalink
Adding random walker shape mode and randomizing rotations by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwebb committed Apr 3, 2019
1 parent 05bae98 commit b20441b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions 04-different-shapes/js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ const sketch = function (p5) {
switch(currentWalkerShape) {
case 'Triangle':
numPoints = 3;
params.rotation = 30;
break;
case 'Square':
numPoints = 4;
params.rotation = 45;
break;
case 'Pentagon':
numPoints = 5;
break;
case 'Hexagon':
numPoints = 6;
break;
case 'Random':
numPoints = parseInt(p5.random(3,6));
break;
}

// Rotate the particle a random amount
params.rotation = p5.random(360);

// Use a random radius to make things interesting
const radius = p5.random(5,11);

Expand Down Expand Up @@ -133,6 +137,10 @@ const sketch = function (p5) {
reset();
break;

case '5':
currentWalkerShape = 'Random';
reset();
break;
}
}
}
Expand Down

0 comments on commit b20441b

Please sign in to comment.