Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (i = 0; i < numAdjacentPoints; i++) {
- // set some shorthands
- curr_point = adjacentPoints[i];
- // if there is no previous point, we start with 0
- prev_point = ((i === 0) ? {p: {end: 0}} : adjacentPoints[i-1]);
- // initiate a probability object
- curr_point.p = {};
- // set a start value (the start value is the previous point's end value)
- curr_point.p.start = prev_point.p.end;
- // set an end value (the start value + the point's brightness' share of totalBrightness)
- // -> points with higher darkness (255-b) are more have a higher share -> higher probability to get grown on
- curr_point.p.end = curr_point.p.start + (255 - curr_point.b) / totalBrightness;
- // if the random value is between the current point's p values, it gets grown on
- if (curr_point.p.start < rand < curr_point.p.end) {
- // add the new point to the path array
- path[path.length] = curr_point;
- // set the point's brightness to white -> it won't come into range any more
- curr_point.b = 255;
- console.log(" we've got a winner! new point is at "+curr_point.x+":"+curr_point.y);
- console.log(" "+curr_point.p.start.toFixed(2)+" < "+rand.toFixed(2)+" < "+curr_point.p.end.toFixed(2));
- }
- };
- we've got a winner! new point is at 300:132 mycelium.php:269
- 0.56 < 0.53 < 0.67 mycelium.php:270
- we've got a winner! new point is at 301:130 mycelium.php:269
- 0.67 < 0.53 < 0.78 mycelium.php:270
- we've got a winner! new point is at 301:131 mycelium.php:269
- 0.78 < 0.53 < 0.89 mycelium.php:270
- we've got a winner! new point is at 301:132 mycelium.php:269
- 0.89 < 0.53 < 1.00
- if (curr_point.p.start < rand && rand < curr_point.p.end) {
- if (curr_point.p.start < rand < curr_point.p.end) {
- if ((curr_point.p.start < rand) < curr_point.p.end) {
- if (0 < 0.67) {
- if (curr_point.p.start < rand < curr_point.p.end)
- if (curr_point.p.start < rand && rand < curr_point.p.end)
Add Comment
Please, Sign In to add comment