/**
* randomstem4 to draw a bunch of stems of a nof segments, with decreasing random dev with height, and left or right direction
* Mod of randomstem3 - now the nofsegments is also random
* Draw new one by mouseclick, also clean screen by any key press.
*
* By Zs Ruttkay on 18.2.2009 using processing 1.0.1
*/
int maxdx=80; // initial deviation along x for segmenting points from vertical
int dy; // size of pixels to forward on y for a segment
int x, y; // location of the root for the next segment
int nofSegments = 5; // MAXIMUM nof segments
void setup() {
size(400,400);
background(255);
strokeWeight(5);
smooth();
x = width/2;
y = height;
dy = height/(nofSegments+1);
noLoop();
}
void draw () {
int rx = 0;
int leftright = int(random(0, 2)); // integer 0 or 1
if (leftright ==0) leftright-=1; // now leftright is -1 0r 1;
int sg = int(random(2, nofSegments+1)); //actual nof segments, min is 2
//dy = height/(sg+1); // if you comment this out the segments will not be of uniform length each
for (int j=0; j