PVector rootNoise = new PVector(random(123456), random(123456));
weeds = new SeaWeed[nbWeeds];
for (int i = 0; i < nbWeeds; i++)
weeds[i] = new SeaWeed(map(i, 0, nbWeeds, -20, width+20), 0, (int)map(i, 0, nbWeeds, 110, 35));
rootNoise.add(new PVector(.01, .01));
for (int i = 0; i < nbWeeds; i++)
float R, G, B, Rspeed, Gspeed, Bspeed;
final static float minSpeed = .6;
final static float maxSpeed = 1.8;
final static float minR = 220;
final static float maxR = 255;
final static float minG = 70;
final static float maxG = 120;
final static float minB = 0;
final static float maxB = 40;
Rspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
Gspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
Bspeed = (random(1) > .5 ? 1 : -1) * random(minSpeed, maxSpeed);
Rspeed = ((R += Rspeed) > maxR || (R < minR)) ? -Rspeed : Rspeed;
Gspeed = ((G += Gspeed) > maxG || (G < minG)) ? -Gspeed : Gspeed;
Bspeed = ((B += Bspeed) > maxB || (B < minB)) ? -Bspeed : Bspeed;
final static float DIST_MAX = 4;
final static float maxNbSeg = 100;
final static float minNbSeg = 35;
final static float maxWidth = 50;
final static float minWidth = 11;
final static float FLOTATION = -3.5;
MyColor myCol = new MyColor();
SeaWeed(float p_x, float p_y, int p_nbSegments)
nbSegments = p_nbSegments;
pos = new PVector[nbSegments];
cols = new color[nbSegments];
rad = new float[nbSegments];
mouseDist = map(nbSegments, minNbSeg, maxNbSeg, 22, 50);
for (int i = 0; i < nbSegments; i++)
pos[i] = new PVector(x, i * DIST_MAX);
cols[i] = myCol.getColor();
PVector mouse = new PVector(mouseX, mouseY);
pos[0] = new PVector(x, y);
for (int i = 1; i < nbSegments; i++)
float n = noise(rootNoise.x + .002 * pos[i].x, rootNoise.y + .002 * pos[i].y);
float noiseForce = (.4 - n) * 4;
pos[i].y -= map(i, 1, nbSegments, FLOTATION, .6*FLOTATION);
float d = PVector.dist(mouse, pos[i]);
PVector tmpPV = mouse.get();
tmpPV = PVector.sub(mouse, tmpPV);
PVector tmp = PVector.sub(pos[i-1], pos[i]);
pos[i] = PVector.sub(pos[i-1], tmp);
for (int i = 0; i < nbSegments; i++)
vertex(pos[i].x, pos[i].y);
ellipse(pos[i].x, pos[i].y, r, r);
cols[0] = myCol.getColor();
for (int i = nbSegments-1; i > 0; i--)